json-server icon indicating copy to clipboard operation
json-server copied to clipboard

Issue with PUT 404 not found

Open sciences44 opened this issue 9 years ago • 6 comments

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 !

sciences44 avatar Dec 14 '16 12:12 sciences44

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.

typicode avatar Dec 14 '16 15:12 typicode

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!

sciences44 avatar Dec 14 '16 18:12 sciences44

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?

riyazmulla51 avatar Apr 26 '20 14:04 riyazmulla51

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.

It is happening to me right now: image

SalahAdDin avatar Jan 10 '25 06:01 SalahAdDin

+1 w/ v0.17.4

image

percebus avatar Jan 12 '25 16:01 percebus

+1 w/ v0.17.4

image

wanna open a new issue?

SalahAdDin avatar Jan 13 '25 17:01 SalahAdDin