Hi Twitch developers community,
I am building react app to display the top games by calling Twitch API. So far in https://dev.twitch.tv/console
- I have registered my app in console given a name,
- I have my redirect URL set to : http://localhost
- I created my client secret
I am not using any server like Express.js, so there is no server-to-server use case here.
My current goal is to simply using Axios to invoke twitch API like top-games: https://api.twitch.tv/helix/games/top
and then render the payload on my dashboard
This is my code for creating Axio instance here:
const api = axios.create({
headers: {
"client_id": "my client id",
"client_secret": 'my client secret',
"redirect_uri": 'http://localhost',
"grant_type": "client_credentials"
},
});
I am getting CORS error everytime when making the api call, the error message capture in console:
Access to XMLHttpRequest at 'https://api.twitch.tv/helix/games/top' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field grant_type is not allowed by Access-Control-Allow-Headers in preflight response.
What did I do wrong here ?Preformatted text