"Why isn't my fetch POST request sending data correctly?"
Hey folks,
I’ve been banging my head against the wall trying to get my fetch POST request to work. The request goes through, but the server ain’t getting the data I’m sending.
Here’s my code:
```js
fetch('/api/data', {
method: 'POST',
body: JSON.stringify({ name: 'John' }),
})
```
Am I missing something obvious? Do I need to set headers or something?
Also, how do I even check what’s being sent? Dev tools show the request, but the payload looks empty.
Any help’s appreciated—thanks!
(PS: If this is a common mistake, just call me out lol)
Hey folks,
I’ve been banging my head against the wall trying to get my fetch POST request to work. The request goes through, but the server ain’t getting the data I’m sending.
Here’s my code:
```js
fetch('/api/data', {
method: 'POST',
body: JSON.stringify({ name: 'John' }),
})
```
Am I missing something obvious? Do I need to set headers or something?
Also, how do I even check what’s being sent? Dev tools show the request, but the payload looks empty.
Any help’s appreciated—thanks!
(PS: If this is a common mistake, just call me out lol)
