Skip to content

Is it possible to create a custom fetch with the dispatcher option preset #2167

Answered by mcollina
gr2m asked this question in Q&A
Discussion options

You must be logged in to vote

Is it possible to create a new fetch instance with the dispatcher option preset?

I don't understand the question, what kind of API are you looking for?
fetch() is just a function, so no one stops you from doing:

function myFetch (url, opts) {
  opts ||= {}
  opts.dispatcher = new MyAgent()
  return fetch(url, opts)
}

Or are you looking for some kind of other utilities?

Background is that we are upgrading https://github.com/octokit to use the native fetch method by default. We currently support an agent option which I now understand is incompatible with undici's fetch. Instead of replacing the agent option with a dispatcher option, I wonder if we can have folks create a custom fetch met…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@mcollina
Comment options

@longzheng
Comment options

@bruce-c-liu
Comment options

@gr2m
Comment options

@bruce-c-liu
Comment options

Answer selected by gr2m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants