Fetch with POST method ignores body

I’m trying to bridge a Tawk.to webhook to Slack.

I’ve got a fetch with the URL, method (POST) and body. But it seems to not be sending the body.

I get a 400 error and if I export the request (in the Network tab in DevTools) as curl I can see there’s no body.

See this gist for the worker and the curl: https://gist.github.com/nachokb/78d2ec397ef318fe6602f798403c2b59

Is this behavior expected?


— nachokb

I checked the docs, you probably need to set Content-type: application/json header.

1 Like

I really wished that would help. But no difference (updated gist).

Still no body in the request. Weird.

Thanks anyway!

Can you try it like this:

  await fetch(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    body: "some payload" // body

yes, I had, indeed, tried it like that as well, with the same results

tried it again just in case, no difference :man_shrugging:

tried with an array body, but it makes no difference :frowning:

I believe there’s some CORS issue, checking