Skip to content

Commit

Permalink
Revert "Update base-client.ts"
Browse files Browse the repository at this point in the history
This reverts commit 69f2125.
  • Loading branch information
WilliamBergamin committed Aug 29, 2023
1 parent 69f2125 commit d857639
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions src/base-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,14 @@ export class BaseSlackAPIClient implements BaseSlackClient {
const body = serializeData(data);

const token = data.token || this.#token || "";
const request = new Request(url, {
const response = await fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": getUserAgent(),
},
body,
});
const response = await fetch(request);

if (!response.ok) {
throw await this.createHttpError(response);
}
Expand Down Expand Up @@ -110,24 +107,3 @@ export function serializeData(data: Record<string, unknown>): URLSearchParams {

return new URLSearchParams(encodedData);
}

function getUserAgent() {
const userAgents = [];
userAgents.push(`Deno/${Deno.version.deno}`);
userAgents.push(`OS/${Deno.build.os}`);
userAgents.push(
`deno-slack-api/${getImportVersion()}`,
);
return userAgents.join(" ");
}

function getImportVersion() {
try {
const url = new URL(import.meta.url);
if (url.protocol === "file:") {
console.log("this module was loaded locally");
}
} catch (error) {
throw Error("no module found");
}
}

0 comments on commit d857639

Please sign in to comment.