aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src/lib
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-08-08 19:12:29 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-08-08 19:12:29 +0200
commit00356d669c765b9f9b47d7a619d73d734fffd594 (patch)
treeda6fcb1fd817a5b5ef3abaa8cfb6eea12b797555 /web/pw-server/src/lib
parentcf52ab6f7f4f96d552b2c6c828fc40704460046f (diff)
downloadplanetwars.dev-00356d669c765b9f9b47d7a619d73d734fffd594.tar.xz
planetwars.dev-00356d669c765b9f9b47d7a619d73d734fffd594.zip
properly initialize fetch in ApiClient
Diffstat (limited to 'web/pw-server/src/lib')
-rw-r--r--web/pw-server/src/lib/api_client.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/web/pw-server/src/lib/api_client.ts b/web/pw-server/src/lib/api_client.ts
index 2eaa762..706d958 100644
--- a/web/pw-server/src/lib/api_client.ts
+++ b/web/pw-server/src/lib/api_client.ts
@@ -1,3 +1,4 @@
+import { browser } from "$app/env";
import { get_session_token } from "./auth";
export type FetchFn = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
@@ -15,8 +16,8 @@ export class ApiClient {
constructor(fetch_fn?: FetchFn) {
if (fetch_fn) {
this.fetch_fn = fetch_fn;
- } else {
- this.fetch_fn = fetch;
+ } else if (browser) {
+ this.fetch_fn = fetch.bind(window);
}
// TODO: maybe it is cleaner to pass this as a parameter