query that i am trying to invoke using node js package.
                  
                  
                  
                  
                  
                  
                  
                  
                  let req = {
                  
                  
                   key: "value"
                  
                  
                  }
                  
                  
                  let res = {
                  
                  
                  key: "value"
                  
                  
                  }
                  
                  
                  logIntoDb = (req,res,code) =>{
                  
                  
                      let connection =  mysql.createConnection(dbProps);
                  
                  
                      
                  
                  
                       connection.connect((err)=>{
                  
                  
                              //callback
                  
                  
                              if(err){
                  
                  
                                  throw err;
                  
                  
                              }else{
                  
                  
                                  console.log("CONNECTED");
                  
                  
                              }
                  
                  
                          }); 
                  
                  
                      var values = [ JSON.stringify(req), JSON.stringify(res), code];
                  
                  
                      let query = "INSERT INTO request_response_tracker (`num_of_requests`, `request`, `response`, `response_code`) VALUES ?";
                  
                  
                      console.log(JSON.stringify(req));
                  
                  
                      connection.query(query,values,(err)=>{
                  
                  
                          console.log(err);
                  
                  
                      })
                  
                  
                  }
                  
                  
                  
                  
                  
                  Although due to some reason its throwing a syntax error. I am trying to store the request and response body of my api in my database. any suggestions how to pull this through?
                  
                  
                
do you need to wrap ? with ""?
maybe try VALUES (?, ?, ?, ?) and pass them individually
Обсуждают сегодня