Skip to content

Commit

Permalink
stick the api client on window for fun
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Nov 17, 2023
1 parent 17408f6 commit 7ed6c19
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libs/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7ed6c19

Please sign in to comment.