I have a function like so:
check_auth(){ fetch(Urls.check_auth(), { credentials: 'include', method: 'GET' }).then(response => { if(response.ok) return response.json(); }).then(json => { return json.user_logged_in; }); } And then I try to do this:
if(this.check_auth()){ // do stuff } else { // do other stuff } But, this.check_auth() is always undefined.
What am I missing here? I thought that within fetch's then() was where the resolved Promise object was therefore I thought that I'd get true when the user was logged in. But this is not the case.
Any help would be greatly appreciated.