inline optional id token auth headers

This commit is contained in:
Patrik Oldsberg
2021-02-10 13:58:12 +01:00
parent 2392cbf8ee
commit eacf540bbd
3 changed files with 12 additions and 21 deletions
@@ -39,15 +39,12 @@ export class KubernetesBackendClient implements KubernetesApi {
): Promise<any> {
const url = `${await this.discoveryApi.getBaseUrl('kubernetes')}${path}`;
const idToken = await this.identityApi.getIdToken();
const headers = {
'Content-Type': 'application/json',
} as { [header: string]: string };
if (idToken) {
headers.authorization = `Bearer ${idToken}`;
}
const response = await fetch(url, {
method: 'POST',
headers,
headers: {
'Content-Type': 'application/json',
...(idToken && { Authorization: `Bearer ${idToken}` }),
},
body: JSON.stringify(requestBody),
});