I can't understand why when I send a post request in Postman I'm getting back a 404 error. The code is attached below. Would appreciate help
CodePudding user response:
To fix that issue just put in line 11router.post('')
and it's will work
CodePudding user response:
You are defining your Express server to use productRouter in path /api/users/products so think of that as a base path for other paths/methods handled in productRouter.
Like answered in earlier answer, adding a / in the end of your URL in Postman will point to the correct path in your Express server.
Probably more better approach would be to add / in the end of the path in index.js app.use('/api/products/', productRoute)
and then your router should work as intended.
CodePudding user response:
Thanks to everyone who tried to help, the problem was my path in postman I forgot to delete users from it