Hi,
I’m overriding the fetch and xhr functions in the browser, for analytics, and more… it must be in the browser.
this is how I do it:
BindFetchApi() {
if (typeof (window.fetch) === 'function') {
const originalFetch = window.fetch;
const clazz = this;
window.fetch = function (url, options) {
try {
let clonedResponse = null;
let originalResponse = null;
if (typeof url === 'string') {
return originalFetch(url, options)
.then((response) => {
originalResponse = response;
clonedResponse = response.clone();
return clonedResponse.text();
})
.then((responseText) => {
})
.then(() => originalResponse)
.catch((e) => originalResponse);
} else {
return originalFetch(url, options);
}
} catch (error) {
return originalFetch(url, options);
}
};
}
}
I don’t know why exactly graphql requests don’t pass through the fetch function above.
is there a way to do that ?
thanks