Use ngx-restangular to handle account API.

This commit is contained in:
Alexis Lahouze
2017-07-16 10:37:52 +02:00
parent 8b62380c52
commit 6244b817d8
6 changed files with 40 additions and 35 deletions

View File

@ -9,13 +9,28 @@ import { BrowserModule } from '@angular/platform-browser';
import { UpgradeModule } from '@angular/upgrade/static';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { RestangularModule } from 'ngx-restangular';
import { AccountModule } from './accounts/account.module';
import { ApiBaseURL } from './app.config';
@NgModule({
imports: [
BrowserModule,
UpgradeModule,
AccountModule
AccountModule,
RestangularModule.forRoot((RestangularProvider) => {
RestangularProvider.setBaseUrl(ApiBaseURL);
// Inject JSON in error instead the full response object.
RestangularProvider.setErrorInterceptor(
function(response, subject, responseHandler) {
// TODO Alexis Lahouze 2017-07-16 Handle 401 error.
subject.error(response.json());
return false;
}
);
})
]
})