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
}
},
})