Skip to content
Advertisement

Node.js getting Uncaught error: invalid input syntax for type integer: “NaN”

I am very new to JS and I’m trying to create an API using node.js however I’m getting the error:

JavaScript

The requests are fine when I do a GET and POST request but I’m having trouble with the PUT and DELETE. I get the same error with both requests. Here is my code:

JavaScript

I am very much new to this and if you spot where I went wrong I would very much appreciate and explanation for me to better understand it and never make this mistake again. Thank you.

Advertisement

Answer

As far as I can see, req.params.id is undefined, because you are not telling express that route should receive a param.

Change this:

JavaScript

To this:

JavaScript

And when you do the PUT or DELETE request, the endpoint should look like this: /profiles/

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement