Skip to content

Example of using custom fetch #1516

Answered by drwpow
jludwiggreenaction asked this question in Q&A
Discussion options

You must be logged in to vote

Oh the any type could probably be improved; that’s just to prevent errors with 3rd-party libraries.

It implements the fetch() API perfectly, so if you wanted to connect it to Axios, you’d have to add a fetch-compatible wrapper, like:

const client = createClient({
  fetch(url: string, options: RequestInit) {
    return axios({ url, ...options });
  }
});

Here is the line of code that gets called at runtime.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jludwiggreenaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants