I'm trying to get my request to go through to a online game API that I can't seem to get working. I'm using the Fetch API, and some request require Authorization Bearer token, but the request never gets sent with the authorization header.
I have tried
mode: 'no-cors',
credentials: 'include'
and obviously putting the Authorization in the header like so
header: { 'Authorization': 'Bearer TOKEN' }
but the request still does not go with the authorization. Can anyone point me in the right direction?
EDIT Heres the way I am making the request
fetch(URL, {
credentials: 'include',
header: {
'Authorization': 'Bearer TOKEN'
}
})
The key name should be headers, not header.
fetch(URL, {
credentials: 'include',
headers: {
'Authorization': 'Bearer TOKEN'
}
})
Read the documentation
Keys can be passed either via query parameter or HTTP header. Guildwars API servers do not support preflighted CORS requests, so if your application is running in the user's browser you'll need to use the query parameter.
To pass via query parameter, include "?access_token=" in your request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With