If the problem is that you want to have a different instance of the AbortController every time you call fetch in the same endpoint, you could simply have a function like this:
Is basically a curried version of fetch that returns a tuple with the response and the abort function, every time you call it you get a new AbortController.
Interesting solution, no need to create custom promise here. I went the custom promise route because I was approaching it in an object-oriented way for another post.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
If the problem is that you want to have a different instance of the
AbortControllerevery time you callfetchin the same endpoint, you could simply have a function like this:Is basically a curried version of
fetchthat returns a tuple with theresponseand theabortfunction, every time you call it you get a newAbortController.Cheers!
Interesting solution, no need to create custom promise here. I went the custom promise route because I was approaching it in an object-oriented way for another post.