At least 2 parameter(s) provided but only 1 parameter(s) present in query

When you encounter the error message “at least 2 parameter(s) provided but only 1 parameter(s) present in query”, it means that a function or a query requires a certain number of parameters to be passed, but you have only provided one parameter instead of the expected two or more.

Let’s illustrate this with an example. Suppose we have a function called “addNumbers” that takes two parameters, “num1” and “num2”, and returns their sum. Here’s how the function might be defined in JavaScript:

    
function addNumbers(num1, num2) {
  return num1 + num2;
}
    
  

If you mistakenly call this function with only one parameter:

    
let result = addNumbers(5);
    
  

You will encounter the error “at least 2 parameter(s) provided but only 1 parameter(s) present in query” because the function expects two parameters, but you have only provided one. To fix this, you need to pass the second parameter when calling the function, like this:

    
let result = addNumbers(5, 3);
console.log(result); // Output: 8
    
  

In the corrected example, we pass both 5 and 3 as parameters to the “addNumbers” function, and it returns the sum, which is 8. This time, the function receives the correct number of parameters and executes without any errors.

Same cateogry post

Leave a comment