callApi() {
var token = `Bearer ${JSON.parse(localStorage.getItem("v1@CacheToken")) ["access_token"]}`;
fetch('/apiName', {
method: 'GET',
headers: {
Authorization: token
}
})
.then(response => response.json())
.then(data => {
console.log(data);
var faviconurl = data.data.icoPath;
if (data.data.icoPath == null || data.data.icoPath == "") {
faviconurl = "/public/favicon.ico";
}
var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = faviconurl;
document.getElementsByTagName('head')[0].appendChild(link);
})
.catch(error => console.error('Error:', error));
}
<link id="ico" rel="icon" href="/public/favicon.ico" />