JSON.stringify() is just the translator between JS and the server. Without it, the server’s like "??? I don’t speak JS objects."
For understanding javascript post requests, I’d say:
1. Start with fetch.
2. Always set headers (usually 'Content-Type': 'application/json').
3. Stringify your body.
4. Handle the response (and errors!).
FreeCodeCamp’s tutorial on fetch is gold.
For understanding javascript post requests, I’d say:
1. Start with fetch.
2. Always set headers (usually 'Content-Type': 'application/json').
3. Stringify your body.
4. Handle the response (and errors!).
FreeCodeCamp’s tutorial on fetch is gold.
