Skip to content

Commit

Permalink
chore: decide header according to the access token
Browse files Browse the repository at this point in the history
  • Loading branch information
openoms committed Nov 24, 2023
1 parent 7a715a9 commit 1c7aa64
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/extension/background-script/connectors/galoy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,25 @@ class Galoy implements Connector {
}

async request(query: { query: string }) {
const headers: Headers = {
Accept: "application/json",
"Content-Type": "application/json",
};

if (
this.config.accessToken.startsWith("blink_") ||
this.config.accessToken.startsWith("galoy_staging_")
) {
headers["X-API-KEY"] = this.config.accessToken;
} else {
headers.Authorization = `Bearer ${this.config.accessToken}`;
}

const reqConfig: AxiosRequestConfig = {
method: "POST",
url: this.config.url,
responseType: "json",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer ${this.config.accessToken}`,
},
headers: headers,
adapter: fetchAdapter,
};
reqConfig.data = query;
Expand All @@ -364,6 +374,10 @@ class Galoy implements Connector {
}
}

type Headers = {
[key: string]: string;
};

type GaloyDefaultAccount = {
defaultWalletId: string;
wallets: {
Expand Down

0 comments on commit 1c7aa64

Please sign in to comment.