- Joined
- Jul 1, 2023
- Messages
- 1
- Reaction score
- 0
hello,
i am working on an app with spotify API and i just cant get past this error that doesn't allow me to get information using the API. when i send a get request, i keep getting a 403 error. what is wrong with my code? i know my formatting is correct, but if anyone knows if I'm missing something with axios configuration then please help.
here is my code for the method in concern:
const fetchTopSongs = async (accessToken) => {
try {
const headers = {
Authorization:
};
console.log(urlCode)
console.log(accessToken)
await axios.get(
setTopSongs(response.data.items);
})
console.log(topSongs);
} catch (error) {
console.log(error);
}
};
as you can see i am testing it by checking console, but that doesn't help the problem and i get this error:
AxiosError {message: 'Request failed with status code 403', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: XMLHttpRequest, …}
if you get this then please help, thanks
i am working on an app with spotify API and i just cant get past this error that doesn't allow me to get information using the API. when i send a get request, i keep getting a 403 error. what is wrong with my code? i know my formatting is correct, but if anyone knows if I'm missing something with axios configuration then please help.
here is my code for the method in concern:
const fetchTopSongs = async (accessToken) => {
try {
const headers = {
Authorization:
Bearer ${accessToken}
,};
console.log(urlCode)
console.log(accessToken)
await axios.get(
https://api.spotify.com/v1/me/top/tracks?time_range=${timeRange}&limit=25
, {headers}).then((response) => {setTopSongs(response.data.items);
})
console.log(topSongs);
} catch (error) {
console.log(error);
}
};
as you can see i am testing it by checking console, but that doesn't help the problem and i get this error:
AxiosError {message: 'Request failed with status code 403', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: XMLHttpRequest, …}
if you get this then please help, thanks