File

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

Constructor

constructor()
import {Injectable} from '@angular/core';
// import {Http, Headers, Response} from '@angular/http';
// import {HttpClient} from '@angular/common/http';
// import {Observable} from 'rxjs/Observable';

// import {ConfigService} from './config.service';
// import {AuthenticationService} from './authentication/authentication.service';
import {Api} from '../../shared/api';


@Injectable()
export class ApiService extends Api {
    // public httpHeaders: Headers;

    // constructor(public http: Http, public httpClient: HttpClient, private config: ConfigService, public authenticationService: AuthenticationService) {
    // constructor(public httpClient: HttpClient, private config: ConfigService) {
    constructor() {
        super();
       // this.httpHeaders = new Headers();
    }

    /**
     *  REST HANDLERS: add Observables to Api: todo: use HttpClient
     **/

    // public postObservable(path, data) {
    //     // return this.httpClient.post(`${this.baseUrl}${path}`, JSON.stringify(data), { headers: this.httpHeaders});
    //     return this.http.post(`${this.baseUrl}${path}`, JSON.stringify(data), {headers: this.httpHeaders});
    // }
    //
    // public getObservable(path, params: any = undefined) {
    //     // todo: query params
    //     if (params) {
    //         // path += '?';
    //         // Object.keys(params).forEach(key => path += key + '=' + params[key] + '&');
    //     }
    //     // return this.httpClient.get(`${this.baseUrl}${path}`, { headers: this.httpHeaders});
    //     let result = this.http.get(`${this.baseUrl}${path}`, {headers: this.httpHeaders});
    //     // if(result.data && result.data[this.idField]) {
    //     //     this.entities[result.data[this.idField]] = result;
    //     // }
    //     return result;
    // }
    //
    // public patchObservable(path, id, data) {
    //     // return this.httpClient.put(`${this.baseUrl}${path}/${id}`, JSON.stringify(data), { headers: this.httpHeaders});
    //     return this.http.put(`${this.baseUrl}${path}/${id}`, JSON.stringify(data), {headers: this.httpHeaders});
    // }
    //
    // public deleteObservable(path, id) {
    //     // return this.httpClient.delete(`${this.baseUrl}${path}/${id}`, { headers: this.httpHeaders});
    //     return this.http.delete(`${this.baseUrl}${path}/${id}`, {headers: this.httpHeaders});
    // }

}

results matching ""

    No results matching ""