Share feedback, ideas and get community help

D
F
M
a
g

Stumped on webhook return value

I think I've tried every possible variation, and even turned to ChatGPT to help, to avail. I am trying to use the 'set variable' block to trigger a webhook, return a response, and save the response to the variable but I'm not getting anything to display. Here's the code inside the 'set variable' block with a variable name of 'authorization':

const webhookUrl = 'https://api.pbt.io/v2/96d049d4-613c-4623-8f5a-3c8cc577da54';
const response = await fetch(webhookUrl, {
method: 'POST', // or 'PUT'
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
'location': {{location}},
'authorization_code': {{authorization_code}}
})
});
const authorization = await response.json;
return JSON.stringify(authorization);

The values being sent to the webhook are working perfectly. The value being returned from the webhook is a simple JSON as follows:

[
{
"authorization": "authorization failed"
}
]

I then have another block right after where I display the 'authorization' in a text block but it comes up blank. Nothing appears in the console for errors or anything else.

All I want to do is populate the 'authorization' variable with the response value from the webhook.
B
R
5 comments
The HTTP Request is made for this
Is there any reason why you are not using the HTTP request block?
Well, now that makes way more sense. Sometimes it's hard to see the forest through the trees! Thanks dude!
No problem πŸ˜„
Add a reply
Sign up and join the conversation on Discord
Join