From 7ed6c192a973b9c3e2abdf90e92e14fa3ff748fa Mon Sep 17 00:00:00 2001 From: David Crespo Date: Fri, 17 Nov 2023 13:39:02 -0600 Subject: [PATCH] stick the api client on window for fun --- libs/api/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libs/api/index.ts b/libs/api/index.ts index 9e5cd1678..53572a128 100644 --- a/libs/api/index.ts +++ b/libs/api/index.ts @@ -25,6 +25,13 @@ export const api = new Api({ host: process.env.NODE_ENV === 'test' ? 'http://testhost' : '', }) +// add the API client to window for use from the browser JS console. requests +// will use the session cookie, same as normal API calls +if (typeof window !== 'undefined') { + // @ts-expect-error + window.oxide = api.methods +} + export type ApiMethods = typeof api.methods export const useApiQuery = getUseApiQuery(api.methods)