79306305

Date: 2024-12-24 18:41:47
Score: 1
Natty:
Report link

I came across the need to do this when trying to intercept the native fetch api.

In addition to @ChrisHamilton's answer, since for me window had to be at a global scope, I ended up putting this check as well:

if (typeof window !== 'undefined') {
    const { fetch } = window;
    originalFetch = fetch;
}
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • User mentioned (1): @ChrisHamilton's
Posted by: juztcode