await Promise.all([
fetch(`${userIsValid}`, { method: 'GET', credentials: 'include', mode: 'cors'
})
.then(res => {
if (res.status === 401) {
error = true;
window.location = loginUrl;
} else {
this.token = res.api_token;
}
return res.json();
}).then(function(data) {
console.log(data);
})
.then(res => res.json()).catch(err => {
if (error) {
window.location = loginUrl;
}
console.log(err);
}),
fetch(`${baseUrl}/user` + '?api_token=Pwbo7CmLtqAP5TvIHYFZPqkmetJFTi9UZIfxE1GLeBFFJgzZ8DvhdTEiGFxf')
.then(res => {
if (res.status === 401) {
window.location = loginUrl;
}
return res;
})
.then(res => res.json())
.then(res => {
//this.currentUserHotelId = res.primary_hotel_id
this.hotelsMap = new ObservableMap(res.hotels)
this.initialized = true
console.log(res);
})])
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.