Json-server: Issue with PUT 404 not found

Created on 14 Dec 2016  路  3Comments  路  Source: typicode/json-server

Hello,

I have an issue with the PUT request and I don't understand why. The get request works perfectly and the query too.

Here is the watch screen.

image

image

And here is the service.js

image

and the controller.js

image

Do you know what is the trouble ?

Thanks in advance !

Most helpful comment

Hi,

I think it's because the id is passed as a query param (?id=1), PUT /dishes/1 should work.
I don't know though how to fix the JS code so that it's not passed as a query param.

All 3 comments

Hi,

I think it's because the id is passed as a query param (?id=1), PUT /dishes/1 should work.
I don't know though how to fix the JS code so that it's not passed as a query param.

Hi Typicode,

You're right, I have tried it manualy and it worked. I still don't know how to fix it with JS but it's another trouble.

Thank you very much!

Hi, I am new to use json server.
I am using it for multiple files. In module solution scenario i am facing the same issue, like for PUT and PATCH without any id it is giving 400.
//server.js file

put

//for 200 i am sending some custom response depends on conditions

image

//endpoints not working
image

//endpoint working
image

@typicode @AdamCook44 is there anything i am missing here?

Was this page helpful?
0 / 5 - 0 ratings