JSON isn't just something we get from the server, we can also send JSON data!
In TypeScript, two of the main methods we have access to are JSON.parse(), and JSON.stringify().
JSON.stringify() is particularly useful for sending JSON.
As you may expect the JSON stringify() method does the opposite of parse. It takes a JavaScript object or value as input and converts it into a string. This is useful when we need to serialize the objects into strings to send them to our server or store them in a database.
Users need to be able to mark their projects as completed. However, updateProjectById() is passing an invalid value to fetch, causing an error.
The .body property in fetch expects a BodyInit in the RequestInit. — those are just the options we pass to fetch.
type BodyInit =
| Blob
| BufferSource
| FormData
| URLSearchParams
| ReadableStream<Uint8Array>
| Iterable<Uint8Array>
| AsyncIterable<Uint8Array>
| string;
That's a lot of stuff, but mainly we need to pass a JSON string.
Fix the code.