reyesoft / ngx-jsonapi

JSON API client library for Angular 5+ 👌 :: Production Ready 🚀
https://ngx-jsonapi.reyesoft.com/
MIT License
101 stars 52 forks source link

Set dynamic api url (for whole module or specific service) #167

Closed a-radys closed 5 years ago

a-radys commented 5 years ago

Hello, I would like to set the host API dynamically in AppModule according to window.location.origin like this:

imports: [
    NgxJsonapiModule.forRoot({
      url: window.location.origin + '/json/v1/',
    })
  ]

but I can't do it because of AOT build. So my other idea would be to set the host API in specific service like mentioned in https://github.com/reyesoft/ngx-jsonapi/issues/35. Is it possible?

a-radys commented 5 years ago

I managed to make it work just by setting:

imports: [
    NgxJsonapiModule.forRoot({
      url: '/json/v1/',
    })
  ]