Angular2 http in bootstrap

How can I tell to angular2 to wait for something in the bootstrap? My component uses a service, which is provided in the bootstrap, but this service uses one HTTP POST and one HTTP GET, to initalize its values, so when my app bootstraps it says cannot read property of undefined.

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

There is no way to make bootstrap wait. What you can do instead is to only call bootstrap() when the calls are completed.

Something like:

let injector = new Injector.resolveAndcreate([HTTP_PROVIDERS]);
let http = injector.get(Http);
http.get('http://somedomain.com/abc').subscribe(_result => {
  bootstrap(AppComponent, [....]);
});