(no title)
logankeenan | 3 months ago
I thought I'd include an example of replacing fetch for anyone that come across this.
const originalFetch = window.fetch;
window.fetch = function(url, options) {
if (url.includes('/api/user')) {
const mockUser = {id: 1, name: 'John Doe', email: 'john@example.com'};
return Promise.resolve(new Response(JSON.stringify(mockUser)));
}
return originalFetch(url, options);
};
https://developer.mozilla.org/en-US/docs/Web/API/ServiceWork...
recursivedoubts|3 months ago
logankeenan|3 months ago
https://developer.mozilla.org/en-US/docs/Web/API/Response