0
votes

I'm having troube with my post request, for some reason it doesn't seem to be sending the data its supposed to. When I submit the request I get a status 201 which is great but when I check the https://jsonplaceholder.typicode.com/posts the post I send doesn't come up.

Here is my code, I have recreated it in a sandbox.

https://codesandbox.io/s/objective-thunder-322xi?file=/src/components/FormComponent.js

Can someone help me out please, thank you?

1
You can't create a resource on jsonpalceholder's server using POST method. API just fakes it that the resource has been created. See the note under jsonplaceholder - Create a resource - Yousaf
Thank you, I wasn't aware of that. - RogerBanks

1 Answers

0
votes

The JSONPlaceholder guide state that you will get the correct response, but data will not be persisted.

Important: the resource will not be really updated on the server but it will be faked as if.

(source: https://jsonplaceholder.typicode.com/guide.html)

To actually save your data you need to create your own copy of the service. For this use: https://github.com/typicode/json-server.