projects/app-base-library/src/lib/angular/services/base.service.ts
Properties |
|
Methods |
|
constructor(config: ConfigService)
|
||||||
Parameters :
|
Public Async fetchCredentials | ||||
fetchCredentials(url: )
|
||||
Parameters :
Returns :
{}
|
Public config |
config:
|
Type : ConfigService
|
Public credentials |
credentials:
|
Type : any
|
Default value : {}
|
Public isOnline |
isOnline:
|
Default value : Util.isOnline
|
Public restoreLocalModel |
restoreLocalModel:
|
Default value : Storage.restoreLocalModel
|
Public saveLocalModel |
saveLocalModel:
|
Default value : Storage.saveLocalModel
|
Public settings |
settings:
|
Type : any
|
import { Injectable } from '@angular/core';
import { Storage, Util } from './../../shared/index';
import { ConfigService } from './config.service';
declare var Promise: any;
@Injectable()
export class BaseService {
public settings: any;
public credentials: any = {};
public saveLocalModel = Storage.saveLocalModel;
public restoreLocalModel = Storage.restoreLocalModel;
public isOnline = Util.isOnline;
constructor(public config: ConfigService ) {
this.settings = this.config['_config'];
}
public async fetchCredentials(url) {
const self = this;
let result = await fetch(url)
.then(function(response) {
return response.json();
})
.catch(function(error) {
console.log('credentials fetch error:', error.message);
});
Object.keys(result.credentials).forEach(function (key) {
self.credentials[key] = result.credentials[key];
});
return self.credentials;
}
}