I need help. I’m using the command .find() in my web application (express JS and Node) but it doesn’t work. I want to search with multiple words.
It’s quite confusing because when I use the command $all, and I force two words (for exemple, salt or sugar), it works, but when I’m using variables it doesn’t…
I’m attaching some images (the route itself and the function with its fetch):
Here the function with its fetch
Many thanks
2
Answers
You have passed
ingredientBucar1
andingredientBucar2
with + signit will become a single string.
so You are passing ‘sa1’ and ‘azucar’ in ingredientBucar1 and ingredientBucar2, It will be passed to api as ‘sa1’ and ‘azucar’
To overcome this You can pass it in post api and get in
req.body
or you can pass it through search params or pass them through 2 different query params like
your_api_endpoint/:ingredientBucar1/:ingredientBucar2
It’s me, here is the code:
FUNCIONES.JS
function buscarPorIngredientes(){
};
INDEX.JS
`app.get("/busquedaIngredientes/:ingredientes",buscarPorIngredientes2);
function buscarPorIngredientes2(req,res){
};`