AJAX alternative to jQuery


I am not thrilled with the verbosity of jQuery’s ajax syntax. Is it possible to use something other than jQuery when fetching data?

I really like axios as a simple and terse alternative to jQuery.ajax/get/post. It has more options and is much more lightweight than jQuery’s old syntax.

So I tried installing axis.

npm install axios --save
import axios from 'axios';

That didn’t work, and maybe it should have? Build failed, and I’m not sure why.

bower install axios --save

That didn’t fail, but it also didn’t work.

Any thoughts?


https://github.com/stefanpenner/ember-fetch is quite nice. There is also https://github.com/ember-cli/ember-ajax


If you dont want to use jQuery, I would highly recommend you to use vanilla JS. Perhaps write a service, or something like that?



How is .get and .post verbose?


Thanks @jasonmit. That is close to what I need. Fetch only does one thing, and I like it. Used it for a React project. But it doesn’t solve the other verbs.

The problem with using vanilla js is that then I have to write the VERY verbose syntax of the xmlhttprequest then wrapping it in a Promise. So I may as well just stick with jquery.

You just listed 2 verbs out of 4 that are most used in APIs. Yes, jquery does fine with those 2. It does fine for all of them, except PUT/PATCH makes you define settings and then attach callbacks there.

A library like axios is much more succinct and already written for promises and ES6. Best thing to do? Take @stefan and the ember-cli way and make it installable. A fun endeavor when if I have time. For now I will stick with jquery


What verbs doesn’t fetch support? Look at it more closely.


Right here bra’ http://microjs.com/#ajax


I recommend https://github.com/tulios/mappersmith, it’s not just an AJAX alternative but it will fit like a glove.