@bondxge/config
v0.0.6
Published
Angular 6 config file, read config on startup
Downloads
2
Maintainers
Readme
@BondxgeConfig
First, install it.
$ npm install @bondxge/config
Then add config.json file in assets.
Then, import it into your @NgModule:
import { ConfigModule } from '@bondxge/config';
imports : [
ConfigModule.forRoot('assets/config.json'),
]
Then, use it in your component:
import { CONFIG } from '@lbge/config'; CONFIG.find('yourKey');
import { Injectable } from '@angular/core';
import { HttpRequest, HttpInterceptor, HttpHandler, HttpEvent, HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { CONFIG } from '@bondxge/config';
import { tap } from 'rxjs/operators';
@Injectable()
export class BaseUrlInterceptor implements HttpInterceptor {
constructor() {
}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
req = req.clone({
url: CONFIG.find<string>('apiUrl') + req.url
});
return next.handle(req);
}
}