Skip to content

v0.8.0

Latest

Choose a tag to compare

@greeeg greeeg released this 09 May 06:32
· 1 commit to master since this release
59c09ba

This release removes support for lazy queries as react-query skipTokens can now be used. It also updates the config object structure to use an onRequest event handler instead of a static object.

import { getAPIClient } from 'generated/apiClient'

// Before
const apiClient = getAPIClient({
  baseUrl: 'https://petstore.swagger.io/v2',
  headers: {
    Authorization: 'Bearer 1234',
  },
  onError: (error: unknown) => {
    if (error instanceof HTTPRequestError && error.statusCode === 401) {
      // Do something
    }
  },
})

// After
const apiClient = getAPIClient({
  baseUrl: 'https://petstore.swagger.io/v2',
  onRequest: async () => ({
    headers: {
      Authorization: 'Bearer 1234',
    }
  }),
  onError: (error: unknown) => {
    if (error instanceof HTTPRequestError && error.statusCode === 401) {
      // Do something
    }
  },
})