Skip to content

Commit

Permalink
i need to commit this
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperCater committed Oct 5, 2024
1 parent 6c9ac90 commit 1437868
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Classes/Internal/fetchHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class FetchHandler {
}

// biome-ignore lint/suspicious/noExplicitAny: <explanation>
fetch = async (method: HttpMethods, url: ValidUrls, route: string, opts : FetchOptions = {}) : Promise<any> => { // params?: { [key: string | number]: unknown }, body?: { [key: string]: unknown }, usecache = true, cookie? : string) => {
fetch = async (method: HttpMethods, url: ValidUrls, route: string, opts: FetchOptions = {}): Promise<any> => { // params?: { [key: string | number]: unknown }, body?: { [key: string]: unknown }, usecache = true, cookie? : string) => {

let RealUrl = this.urls[url] + route;

Expand All @@ -49,10 +49,10 @@ fetch = async (method: HttpMethods, url: ValidUrls, route: string, opts : Fetch
if (cached && opts.usecache) return cached;

const headers = new Headers();

if (this.CsrfToken) headers.set("X-Csrf-Token", this.CsrfToken);
if (this.cookie) headers.set("Cookie", `.ROBLOSECURITY=${this.cookie}`); // If the cookie is passed as a parameter, use that instead of the default cookie
if (opts.cookie) headers.set("Cookie", `.ROBLOSECURITY=${opts.cookie}`); // If the cookie is passed as a parameter, use that instead of the default cookie
if (this.cookie) headers.set("Cookie", `.ROBLOSECURITY=${this.cookie}`);
if (opts.cookie) headers.set("Cookie", `.ROBLOSECURITY=${opts.cookie}`);
headers.set("Content-Type", "application/json");

const response = await fetch(RealUrl, {
Expand All @@ -61,7 +61,7 @@ fetch = async (method: HttpMethods, url: ValidUrls, route: string, opts : Fetch
headers: headers,
body: opts.body ? JSON.stringify(opts.body) : undefined,
})

if (!this.CsrfToken && response.headers.get("x-csrf-token")) {
this.CsrfToken = response.headers.get("x-csrf-token") as string;
if (response.status === 403) {
Expand Down

0 comments on commit 1437868

Please sign in to comment.