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’,
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);
});