Skip to content
Snippets Groups Projects
Commit 20f4d7b0 authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Catch error in case api url of Person entity wasn't found

parent 006a1608
No related branches found
No related tags found
No related merge requests found
Pipeline #51367 failed
......@@ -120,23 +120,30 @@ export class AuthKeycloak extends AdapterLitElement {
if (newPerson && this.loadPerson) {
JSONLD.getInstance(this.entryPointUrl).then((jsonld) => {
// find the correct api url for the current person
// we are fetching the logged-in person directly to respect the REST philosophy
// see: https://github.com/api-platform/api-platform/issues/337
const apiUrl = jsonld.getApiUrlForEntityName("Person") + '/' + that.personId;
fetch(apiUrl, {
headers: {
'Content-Type': 'application/ld+json',
'Authorization': 'Bearer ' + that.token,
},
})
.then(response => response.json())
.then((person) => {
that.person = person;
try {
// find the correct api url for the current person
// we are fetching the logged-in person directly to respect the REST philosophy
// see: https://github.com/api-platform/api-platform/issues/337
const apiUrl = jsonld.getApiUrlForEntityName("Person") + '/' + that.personId;
fetch(apiUrl, {
headers: {
'Content-Type': 'application/ld+json',
'Authorization': 'Bearer ' + that.token,
},
})
.then(response => response.json())
.then((person) => {
that.person = person;
this.sendSetPropertyEvents();
this._setLoginStatus(this._loginStatus, true);
});
} catch (error) {
console.warn(error);
that.person = null;
this.sendSetPropertyEvents();
this._setLoginStatus(this._loginStatus, true);
});
}
}, {}, that.lang);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment