question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Export fetch function

See original GitHub issue

Exporting the fetch function through module.exports would allow me to use the polyfill instead of buggy browser implementations. For example, current Chrome Canary incorrectly throws on 504 response, without any sensible way of detecting the cause of error in the catch handler.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bamsebjrncommented, Aug 8, 2018

excitera me sir but what? im jusing tor o chrome

Skickat från min iPhone

8 aug. 2018 kl. 09:19 skrev Jarek Rencz <notifications@github.commailto:notifications@github.com>:

@mislavhttps://github.com/mislav thanks for a hint 😃

Any faulty browser implementation of fetch is that browser vendor’s problem and should be taken with them.

To a certain extent it’s not always on the browser vendor’s side. E.g.: In a project of mine, where I use fetchI experience a strange behaviour in Firefox <54 where using native fetch it produces POST requests without payload. I was able to reproduce it with 1/500-1000 ratio but I see it in production so it’s a fact.

Enforcing polyfill allows me to make my app usable for such users (those are mostly Firefox 52 users)

And now to the point: Firefox 52 is the last one on Win XP and Win Vista. I don’t have a comfort of telling my users to update their PCs’ OS just because at some point Mozilla did something bad in fetch implementation and then they fixed it (to my best knowledge either silently or accidentally because I found no bug report about such behaviour in Bugzilla)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/github/fetch/issues/180#issuecomment-411311099, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AoPVRO_Qst3Il-tU9tCvRCIkVLxcnGCDks5uOpD2gaJpZM4Fblbf.

1reaction
mislavcommented, Jul 20, 2015

@jpochyla Here is how to force the polyfill.

<script>window.fetch = undefined</script>
<script src=fetch.js></script>

@runn1ng We don’t feel that a module pattern is worth maintaining for this simple polyfill. Any faulty browser implementation of fetch is that browser vendor’s problem and should be taken with them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Export data returned by 'fetch' from a separate .js file in React
The best way is export getData function, remove .then(obj => data ... const getData = async () => fetch("https://api.myjson.com/bins/mp441") ...
Read more >
How to export fetch resuts to other module - JavaScript
I do so with this function: let user = {}; export async function getId() { const response = await fetch( "https://nomoreparties.co/v1/" + `${ ......
Read more >
Four Ways to Fetch Data in React - Cory House
Fetch data from REST APIs in React. React is a focused component library. ... export function getUsers() { return fetch(`${process.env.
Read more >
JavaScript modules - MDN Web Docs
The first thing you do to get access to module features is export them. This is done using the export statement. ... You...
Read more >
Fetch Data in Next.js - Documentation - Prismic
Queries are performed using a client created by the createClient() function exported from prismicio.js. Here's a complete example, querying a document of type ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found