INNER CODE UNIT · TypeScript

useGqlToken

Diizzayy/nuxt-graphql-client · src/runtime/composables/index.ts:126

export function useGqlToken(token: GqlToken, opts?: GqlTokenOptions): void
/**
 * `useGqlToken` adds an Authorization header to every request.
 *
 * @param {object} opts Options for the auth token
 */
export function useGqlToken(opts: GqlTokenOptions & { token: GqlToken }): void
export function useGqlToken(...args: any[]) {
  args = args || []

  const config: TokenOpts = args[0]?.config || args?.[1]?.config
  const refreshData = args[0]?.refreshData ?? args?.[1]?.refreshData ?? true

  let client: GqlClients = args[0]?.client || args?.[1]?.client
  let token: string = typeof args[0] === 'string' || args?.[0] === null ? args[0] : args?.[0]?.token
  if (token) { token = token.trim() }

  client = getGqlClient(client)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…