File

projects/app-base-library/src/lib/angular/services/base.service.ts

Index

Properties
Methods

Constructor

constructor(config: ConfigService)
Parameters :
Name Type Optional
config ConfigService no

Methods

Public Async fetchCredentials
fetchCredentials(url: )
Parameters :
Name Optional
url no
Returns : {}

Properties

Public config
config: ConfigService
Type : ConfigService
Public credentials
credentials: any
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: any
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;
    }

}

results matching ""

    No results matching ""