DEV Community

Cover image for Fetch vs Axios in Javascript

Fetch vs Axios in Javascript

Suman Roy on October 11, 2022

Hello there ! 👋 In this blog, we are going to learn how to implement APIs by using Fetch API and Axios Before we get started, the only p...
Collapse
 
webjose profile image
José Pablo Ramírez Vargas

Quick note: fetch() can be aborted.

const abortC = new AbortController();
var responsePromise = fetch('http://longrunningrequest.example.com', { signal: abortC.signal });
setTimeout(() => abortC.abort(), 1000);
Enter fullscreen mode Exit fullscreen mode

If running in the browser developer tools, Network tab, you'll see that the request's status goes from (pénding) to (canceled).

Collapse
 
suman373_30 profile image
Suman Roy • Edited

Thanks for the update ! Have changed it 😀

Collapse
 
gadingnst profile image
Gading Nasution

Axios can be aborted using AbortController too 😅

Collapse
 
johnnycricket profile image
John Vorwald

Is there any other resources that look at adding a XSRF layer to fetch?

Collapse
 
suman373_30 profile image
Suman Roy

cheatsheetseries.owasp.org/cheatsh...

U might find it useful

Collapse
 
johnnycricket profile image
John Vorwald

Thanks!

Collapse
 
itsroy69 profile image
Jyotirmoy Roy

Well written

Collapse
 
suman373_30 profile image
Suman Roy

Thank you @itsroy69 🙏

Collapse
 
thomasbnt profile image
Thomas Bnt ☕

Nice comparaisons, how did you find this?

Collapse
 
suman373_30 profile image
Suman Roy

Resources from the internet.

Collapse
 
lomapimentel profile image
Info Comment hidden by post author - thread only accessible via permalink
LomaPimentel

Difference between Fetch and Axios in Javascript?is vashikaran possible

Some comments have been hidden by the post's author - find out more