I have this function below that is supposed to fetch data from a Twitch API Endpoint,
But I need to pass a query parameter with a key to_id and a value, and I don't know how to pass query parameters using this npm module,
I think I have to do this in the gameOptions object below,
(Here's a link of the doc: https://www.npmjs.com/package/request#requestoptions-callback)
function gameRequest(accessToken) {
setTimeout(() => {
const gameOptions = {
url: "https://api.twitch.tv/helix/users/follows",
method: "GET",
headers: {
"Client-ID": MY_CLIENT_ID,
Authorization: "Bearer " + accessToken,
},
};
if (!accessToken) {
console.log("No Token");
} else {
console.log(gameOptions);
const gameRequest = request.get(gameOptions, (err, res, body) => {
if (err) {
return console.log(err);
}
console.log(JSON.parse(body));
});
}
}, 2000);
}
url: "https://api.twitch.tv/helix/users/follows?to_id=" + yourID,yourIDvariable doesn't contain any special characters. Make sure you URL encode the url