hello everyone! I want to make a get request on twitch. But I have an error. I write in node js and use axios to make a request.
My code:
import axios from "axios";
axios.post('https://id.twitch.tv/oauth2/token', {
client_id: 'iaxcs84csy2v5mvzueo69y',
client_secret: '6uj5ltv3l7uljc5k',
grant_type: 'client_credentials'
})
.then(function (response) {
console.log(response);
})
axios.get('https://api.twitch.tv/helix/search/channels?query=loserfruit', {
headers: {
'Client-Id': 'iwnng4cs84csy2v5ueo69y',
'Authorization': 'Bearer 1n44alq5a9n4e9oz8j4'
}})
.then(function (response) {
console.log(response);
})
Error:
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "AxiosError: Request failed with status code 401".] {
code: 'ERR_UNHANDLED_REJECTION'
}