We are comparing a library to a native browser method, it seems kinda like comparing an apple to an apple-tree to me. Is this comparison valid?
In a performance-based world, the native method always wins out because of the library weight.
As for interceptors, consider using a service-worker for that kind of operation.
Or, wrap your fetch method, in an "interceptedFetch" method.
Also, there are no async examples here. Fetch is soooo' much more fun and verbose to use when coupled with async functions.
async function getTheThings() {
try {
const request = await fetch('....my-url.json', ...);
const data = await request.json();
// ...do something with data, return, format etc.
} catch(e) {
// handle error
// or throw a new custom that the callee can be setup to handle
}
}
All promises work interchangeably with async. :)
And you only need the expensive polyfills if you support legacy browsers.
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.
We are comparing a library to a native browser method, it seems kinda like comparing an apple to an apple-tree to me. Is this comparison valid?
In a performance-based world, the native method always wins out because of the library weight.
As for interceptors, consider using a service-worker for that kind of operation.
Or, wrap your fetch method, in an "interceptedFetch" method.
Also, there are no async examples here. Fetch is soooo' much more fun and verbose to use when coupled with async functions.
All promises work interchangeably with async. :)
And you only need the expensive polyfills if you support legacy browsers.