async init(force = false) {
let test = this.props;
let error = false;
if (force) {
this.initialized = false
}
if (this.initialized) return
//view config
await Promise.all([
fetch(`${userIsValid}`, { method: 'GET', credentials: 'include', mode: 'cors'
})
.then(res => {
console.log(res.body.json());
if (res.status === 401) {
error = true;
window.location = loginUrl;
} else {
this.token = res.api_token;
}
return {}
})
.then(res => res.json())
.then(res => {
})
.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.