Skip to content

Commit 87f4d8b

Browse files
authored
Stick the api client on window (#1814)
stick the api client on window for fun
1 parent 65ae121 commit 87f4d8b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

libs/api/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ export const api = new Api({
2525
host: process.env.NODE_ENV === 'test' ? 'http://testhost' : '',
2626
})
2727

28+
// add the API client to window for use from the browser JS console. requests
29+
// will use the session cookie, same as normal API calls
30+
if (typeof window !== 'undefined') {
31+
// @ts-expect-error
32+
window.oxide = api.methods
33+
}
34+
2835
export type ApiMethods = typeof api.methods
2936

3037
export const useApiQuery = getUseApiQuery(api.methods)

0 commit comments

Comments
 (0)