Best way to make an ajax request in an addon?

This sounds like a question from 2005 :smiley: Ha!

Ok, we go…

It seems that there are a handful of different ways to configure how an Ember application makes its network requests. Here’s what I’ve seen so far…

  • jQuery/$.ajax
  • fetch
  • Fastboot node fetch polyfill
  • Fastboot njax

I’m writing an addon that makes ajax requests and I want to be able to do it in a way that respects all of these different environments. So far I’ve been using ember-ajax, but it was recently pointed out to me that it relies on jQuery, which a number of Ember applications are no longer using.

So that got me thinking, what’s the best way to make a network request in an Ember addon?


I believe if you use fetch, consuming apps that that use fastboot will need to supply their own polyfill. But I’m no expert – this is just a strong hunch :slight_smile:

1 Like

I think the best choice is ember-fetch.

It doesn’t need jQuery, it works in browser and fastboot. It handles the run loop integration needed for existing ember versions.

The runloop integration stops being an issue in Ember 3.4, because there’s no more autorun assertion. But the fastboot compatibility is still a compelling reason to use it over window.fetch.

It would be great to go on a little quest getting addons to standardize on one thing. Personally I don’t like that we still ship ember-ajax in the default app blueprint. Most likely we should stop now that the runloop integration doesn’t matter.


Awesome! Thank you Ed.