Skip to content

Commit

Permalink
Merge pull request #5179 from SDA-SE/feat/fix-headers
Browse files Browse the repository at this point in the history
Avoid using Headers as it is not supported in the backend
  • Loading branch information
dhenneke committed Mar 30, 2021
2 parents ee01dcf + b196a45 commit 4196c1e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/stupid-moles-joke.md
@@ -0,0 +1,5 @@
---
'@backstage/catalog-client': patch
---

Avoid using Headers as it is not supported in the backend
18 changes: 9 additions & 9 deletions packages/catalog-client/src/CatalogClient.ts
Expand Up @@ -191,9 +191,9 @@ export class CatalogClient implements CatalogApi {
options?: CatalogRequestOptions,
): Promise<void> {
const url = `${await this.discoveryApi.getBaseUrl('catalog')}${path}`;
const headers = new Headers(
options?.token ? { Authorization: `Bearer ${options.token}` } : {},
);
const headers: Record<string, string> = options?.token
? { Authorization: `Bearer ${options.token}` }
: {};
const response = await fetch(url, { method, headers });

if (!response.ok) {
Expand All @@ -207,9 +207,9 @@ export class CatalogClient implements CatalogApi {
options?: CatalogRequestOptions,
): Promise<any> {
const url = `${await this.discoveryApi.getBaseUrl('catalog')}${path}`;
const headers = new Headers(
options?.token ? { Authorization: `Bearer ${options.token}` } : {},
);
const headers: Record<string, string> = options?.token
? { Authorization: `Bearer ${options.token}` }
: {};
const response = await fetch(url, { method, headers });

if (!response.ok) {
Expand All @@ -225,9 +225,9 @@ export class CatalogClient implements CatalogApi {
options?: CatalogRequestOptions,
): Promise<any | undefined> {
const url = `${await this.discoveryApi.getBaseUrl('catalog')}${path}`;
const headers = new Headers(
options?.token ? { Authorization: `Bearer ${options.token}` } : {},
);
const headers: Record<string, string> = options?.token
? { Authorization: `Bearer ${options.token}` }
: {};
const response = await fetch(url, { method, headers });

if (!response.ok) {
Expand Down

0 comments on commit 4196c1e

Please sign in to comment.