

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: JSON Syntax
incomplete
2: JSON Review
incomplete
3: Sending JSON
incomplete
4: Parsing JSON
incomplete
5: XML
incomplete
6: Why Use XML?
incomplete
This lesson's interactive features are locked, please to keep using them
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.