We’ll use fetch and an async action creator to save updated data to the server and update the UI with the result of the update once the save has completed successfully.
In the fetch POST body we are sending the javascript object with name and completed properties.
In the .then(res => res.json()) is the fetch just returning the same back if it is successful? Is this typical of a POST request or is it set up somewhere in this json-server setup?
I have the same question as @ed did. How do we know what is gonna return back in .then()? Or this is the default behavior?
Could you explain why (in clip 17) you decided to change the TodoForm component into a class component please?
I have the same question as @ed did. How do we know what is gonna return back in .then()? Or this is the default behavior?
I think you will always need to get something back from a create (POST) because json-server will allocate the new todo an id (we don't pass the id to the createTodo() function) which is required as a key in the component and also later on when deleting it. You can see this by adding a todo and then looking at it, where it has been added at the end of db.json.