<script>
import { onMount } from 'svelte';
import axios from 'axios';
export let access_token;
let displayName = '';
let errors = [];
const requestAPI = async () => {
try {
const res = await axios.get('https://api.spotify.com/v1/me', {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${access_token}`
}
});
displayName = res.data.display_name || 'User';
} catch (err) {
errors.push(err);
}
};
onMount(() => {
requestAPI();
});
</script>
I tried using Got and normal fetch nothing worked. I have done all authorization properly and also access_token wasn't expired.