DEV Community

Discussion on: How to Abort a Fetch Request in JavaScript using AbortController

 
digitalbrainjs profile image
Dmitriy Mozgovoy • Edited

Probably no, unless you mean that bundling the frontend of your app with webpack requires node.js. But the building process is in no way associated with Web servers. If you need to use it in old-school way directly without building, just import the UMD browser module as a script:

<script src="https://unpkg.com/cp-fetch/dist/cp-fetch.umd.js"></script> 
<script>
const promise1 = cpFetch("https://api.github.com/users/nas5w")
  .timeout(10000)
  .then((res) => res.json())
  .then(console.log, console.warn);

setTimeout(() => promise1.cancel(), 10);
</script>
Enter fullscreen mode Exit fullscreen mode