1

My api expects an api token as a query parameter for GETs and DELETEs and a parameter in the body for PUT/PATCHs and POSTs.

I see in the Ember Guides the inclusion of an API key in a header, but that's not what my api expects. I also saw some old posts that seemed to override the ajax method, but that member is marked private, so I don't think it would be considered the "Ember Way".

Is there a documented "Ember Way" do accomplish this? Or is there any "Best Practices" that most people are following for this?

nPn
  • 16,254
  • 9
  • 35
  • 58

1 Answers1

0

Ember Way Header Customization

Matching Thread setting the access token on every ajax request

Community
  • 1
  • 1
  • I saw both of these, and mentioned them in my question. The api does _not_ expect the key as part of the header, so that does not work unless I change the api on the server. As far as overriding the ajax method, I found this: http://pulkitgoyal.in/add-params-ember-datas-restadapter-ajax-requests/ , which works, but as pointed out in my question the ajax method is marked as private, so that does not seem like a way the Ember developers would want us to do this. – nPn Apr 19 '16 at 14:24
  • Why would the given solution from the ember api guide not be official enought ? Anyhow, if you don´t want to send it in the header you can always send it as an parameter in the url which I would not recommend because your access token is visible to everyone walking by – Christian Stengel Apr 19 '16 at 14:34
  • I don't have a problem with the guide at all and would use it _if_ the existing api I need to talk to supported getting the token from the header, but it does not, so I am trying to _adapt_ Ember to work with an existing api. As far as visibility, this is the request that will be send via ajax we are talking about, not what the user would see in the browser when working with the ember app itself, so unless I am confused, I don't think anyone would see these query parameters displayed in there browsers address bar. – nPn Apr 19 '16 at 14:50
  • @nPn the approach would stay the same except you don´t add header information in the ajax request but alter the url – Christian Stengel Apr 19 '16 at 15:11