angular - Load external config, and use this config for another http call -


for our application need read our configuration external url, http://myhost/config.json. configuration file contains apiurl should use other http requests (rest).

i tried use app_initializer factory method calls our service load config. returns observable.

when open our page request executed our customers. done via http request should use apiurl config.

however, system doesn't wait till first call (to config) ready, apiurl not available yet.

one option wrap each call (pseudo):

this.configservice.getconfig().subscribe(config => {    this.customerservice.getcustomers(config); }) 

this not prefered because other developers should call customerservice directly, , shouldn't bother config.

it should nice when can inject config object in constructor , use directly. possible?

if not, how can make sure config available other api calls (loaded on startup) ? synchronized http.get request.

angular version 4.3.4

it seems when convert observable promise waits correctly.

return configobservable.topromise(); 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -