2

RESTAdapter has the possibility to specify a url for the backend:

DS.RESTAdapter.reopen({
  url: 'https://api.example.com'
});

How can I access this property programmatically? I mean something like: DS.RESTAdapter.get('url') <-This doesn't work

joscas
  • 7,474
  • 5
  • 39
  • 59

3 Answers3

4

You're setting the properties on the class not the instance, thats why you can't retrieve the values. There are two possible solutions.

You can get the values from the prototype

DS.RESTAdapter.prototype.url

or you can instantiate the class and get it from there

DS.RESTAdapter.create().url
Gevious
  • 3,214
  • 3
  • 21
  • 42
1

Quick and dirty ...

NOTE: Please use only for debugging, this API is intern and will cenrtainly change in the future, so don't rely on it.

Assuming you have only one Store in your application:

App.__container__.lookup('store:main').get('adapter.url')

If you are using Chrome Dev Tools you can try to call this from the console, it should print out the url used by the default adapter used by the default Store. But it's discouraged to be used for other then for debugging.

Hope it helps

intuitivepixel
  • 23,302
  • 3
  • 57
  • 51
1

Or

DS.defaultStore.adapter.url
Cyril Fluck
  • 1,561
  • 7
  • 9