Handle webhook requests

I am trying to set up a simple worker which will receive a webhook request and pass the data onto my slack API.

For some reason I cannot get this to work, the request.body is always null, thus I can’t handle the data coming in from the webhook

I have tried sending the data over using postman and it remains null, regardless how I send it.

What is interesting is this forms part of the request message I am getting

"method":"POST","bodyUsed":false,"body":{"locked":false}}

Anyone got any tips, I have tried googling but not having any luck.

Can you post your code and a sample of how your worker is called?

I am running the same issue. Even simple requests like the one below are failing:

addEventListener('fetch', event => {
    event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
    const apiUrl = 'https://slack.com/api';

    const composeReactionObject = {
        name: 'thumbsup',
        channel: `channel-ID-here`,
        timestamp: `timestamp-value-here`,
    }

    if (request.method === 'GET') {
        try {
            const postToSlack = await fetch(`${apiUrl}/reactions.add`, {
                body: composeReactionObject,
                method: 'POST',
                headers: { 'Content-Type': 'application/json', 'Authorization': `slack-token-here` },
            })
            return new Response(JSON.stringify(postToSlack))
        } catch (err) {
            return new Response(`Something went wrong: ${err}`, { status: 404 })
        }
    }
}

This is the response that I receive:

{
  "webSocket": null,
  "url": "https://slack.com/api/reactions.add",
  "redirected": false,
  "ok": true,
  "headers": {},
  "statusText": "OK",
  "status": 200,
  "bodyUsed": false,
  "body": {
    "locked": false
  }
}

What might be going on here? A simple request on Glitch.com goes through.

Thanks for taking a look!

I am not sure if my last reply sent a notification your way, @sandro. So, here is a quick mention. Hoping to see if you have any ideas here. Thanks.