fix: expect api requests to return json (#473)

This commit is contained in:
keeri 2022-05-09 19:43:45 +00:00 committed by GitHub
commit 7593cadd40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,14 +22,21 @@ export class ApiService {
this.node.setLoading(); this.node.setLoading();
} }
} }
let header; let options: any = {
responseType: 'json',
};
if (this.appSettings.settings.serverAuth != null && this.appSettings.settings.serverAuth !== '') { if (this.appSettings.settings.serverAuth != null && this.appSettings.settings.serverAuth !== '') {
header = { options =
headers: new HttpHeaders() Object.assign(
.set('Authorization', this.appSettings.settings.serverAuth) {},
}; options,
{
headers: new HttpHeaders()
.set('Authorization', this.appSettings.settings.serverAuth)
}
);
} }
return await this.http.post(apiUrl, data, header).toPromise() return await this.http.post(apiUrl, data, options).toPromise()
.then(res => { .then(res => {
this.node.setOnline(); this.node.setOnline();
return res; return res;