# Help with Webhooks nodejs

**URL:** <https://discuss.dev.twitch.com/t/help-with-webhooks-nodejs/29818>\
**Category:** API\
**Created:** [January 6, 2021, 10:17pm UTC](https://discuss.dev.twitch.com/t/help-with-webhooks-nodejs/29818 "2021-01-06T22:17:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjosue15](https://avatars.discourse-cdn.com/v4/letter/c/f17d59/32.png) [@cjosue15](https://discuss.dev.twitch.com/u/cjosue15)\
**Post date:** [January 6, 2021, 10:17pm UTC](https://discuss.dev.twitch.com/t/help-with-webhooks-nodejs/29818/1 "2021-01-06T22:17:50Z")

</div>

Hi, im trying to use webhooks for notify when stream is on live, i have a server with nodejs hosted on heroku, I have the correct initial configuration with callback url, but in this url i dont recive anything

async function subscribe() {  
const headers = {  
‘Content-Type’: ‘application/json’,  
‘Client-ID’: ‘clientID’,  
Authorization: ‘Bearer auth’,  
};

```
try {
    const response = await fetch('https://api.twitch.tv/helix/webhooks/hub', {
        method: 'post',
        body: JSON.stringify({
            'hub.mode': 'subscribe',
            'hub.callback': 'https://example.com/twitch/live',
            'hub.topic': `https://api.twitch.tv/helix/streams?user_id=488606177`,
            'hub.lease_seconds': '864000',
            'hub.secret': 'secret',
        }),
        headers: headers,
    });
    console.log(response);
} catch (error) {
    console.log(error);
}

```

}

subscribe();

in the response i have status 202  
url: ‘[https://api.twitch.tv/helix/webhooks/hub](https://api.twitch.tv/helix/webhooks/hub)’,  
status: 202,  
statusText: ‘Accepted’

I have been reading about this, and when twitch response 202, webhooks is created, in my callback route i have this

```
router.get('/twitch/live', (req, res) => {
    console.log(req.query);
    console.log(req.query['hub.challenge'])
    res.send(req.query['hub.callback']).status(200);
});

```

i recive req.query[‘hub.callback’], so get so its means GET peticion of twitch is correct.

but where i recive data of the streamer? i try using a POST route but i dont have any here. please help me ☹

router.post(’/twitch/live’, (req, res) =\> {  
console.log(req.body);  
res.send(req.body).status(200);  
});

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 6, 2021, 10:18pm UTC](https://discuss.dev.twitch.com/t/help-with-webhooks-nodejs/29818/2 "2021-01-06T22:18:39Z")

</div>

Try this example

> **[BarryCarlyon/twitch\_misc](https://github.com/BarryCarlyon/twitch_misc/tree/main/webhooks/handlers/nodejs)**
>
> main/webhooks/handlers/nodejs

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 6, 2021, 10:21pm UTC](https://discuss.dev.twitch.com/t/help-with-webhooks-nodejs/29818/3 "2021-01-06T22:21:52Z")

</div>

> [@cjosue15](#):
>
> ```auto
> router.get('/twitch/live', (req, res) => {
> console.log(req.query);
> console.log(req.query['hub.challenge'])
> res.send(req.query['hub.callback']).status(200);
> });
> 
> ```

This is wrong

` res.send(req.query['hub.callback']).status(200);`

should be

` res.send(req.query['hub.challenge']).status(200);`

You have a callback instead of a challenge

---

<div class="post-metadata">

**Author:** ![cjosue15](https://avatars.discourse-cdn.com/v4/letter/c/f17d59/32.png) [@cjosue15](https://discuss.dev.twitch.com/u/cjosue15)\
**Post date:** [January 6, 2021, 10:37pm UTC](https://discuss.dev.twitch.com/t/help-with-webhooks-nodejs/29818/4 "2021-01-06T22:37:53Z")

</div>

> [@BarryCarlyon](#):
>
> You have a callback instead of a challenge

thanks for your reply, this was the problem, im so stupid jejej.

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [February 5, 2021, 10:37pm UTC](https://discuss.dev.twitch.com/t/help-with-webhooks-nodejs/29818/5 "2021-02-05T22:37:54Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
