Home > other >  Postman post method return 404 for the URL localhost:5001/api/users/products
Postman post method return 404 for the URL localhost:5001/api/users/products

Time:07-13

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

router

index.js

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

  • Related