typicode/jsonplaceholder

POST request posting the same key for each post

Closed this issue · 2 comments

I think in post request, the id should be increased automatically. But when I tried post request in http://jsonplaceholder.typicode.com/users, Id is constant (11) for multiple post. Is this the bug or I am missing something? Please correct me if I am wrong.

sample code is here,

axios
    .post("https://jsonplaceholder.typicode.com/users", {name: "John"})
    .then((res) => {
     console.log(res)
    }

Hi @iamtekson,

It's by design. POST requests are faked and no users are created. So when you make another call to /users you still get 10 users and so another POST to /user will return id: 11.

If you need data to be persisted between calls, you can use json-server locally.

Ok thank you for the explanation. Then I think it is better to close this issue.