I try to fetch an image protected by Bearer token and I want to set it to the src property of an image element
var headers = new Headers();
headers.append("Authorization", "Bearer " + getAccessToken());
var requestOptions = {
method: 'GET',
headers: headers,
redirect: 'follow'
};
fetch("__AUTH_HOST__/storage/o/user/" + getCookie('user_id') + '/' + username + '.png', requestOptions)
.then(response => {
if(response.status == 200){
document.getElementById('image_id').src = something
}
}).catch(error => console.error(error));
is there any way to achieve this? or should I store it somehow locally?