0

I'm getting an error I don't understand when sending the parameters to my method, I thought my query was wrong but I did it manually and mySQL did what it had to do. So the problem is in my code but I don't seem to find where, thanks in advance.

exports.defav = function(id_user, id_restaurant, callback){

console.log(id_user + " " + id_restaurant); //Just making sure i'm reciving correclt
pool.getConnection(function(err, connection){
  if(err){
    console.log(err);
    callback(true);
    return;
  }

  connection.query("DELETE FROM favorites WHERE id_user = ? AND id_restaurant = ?", id_user, id_restaurant, function(err, results) {
    console.log("SUCCESS: Removed from fav ");
    connection.release();
      if(err){
        console.log(err);
        callback(true);
        return;
      }

      callback(results);
    });
  });
};

The error I'm getting is:

throw err; // Rethrow non-MySQL errors ^

TypeError: this._callback.apply is not a function

1 Answer 1

1

Query parameters should be passed in an array:

connection.query("DELETE FROM favorites WHERE id_user = ? AND id_restaurant = ?", [ id_user, id_restaurant ], function(err, results) {
  ...
});
Sign up to request clarification or add additional context in comments.

1 Comment

Omg, I don't know how i missed that, I have a hundred more queries with them and I miss them Ha! Thanks for the help will mark as correct in 4 mins as I have to wait.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.