File

src/app/modules/dashboard/services/usage/usage.service.ts

Constructor

constructor(http: HttpClient)

Constructor

Parameters :
  • http : HttpClient

    HttpClient reference

Methods

getData
getData(url: string)
Returns: void

Properties

http
http: HttpClient

angular HttpClient

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
import { get } from 'lodash-es';

@Injectable({
  providedIn: 'root'
})
export class UsageService {

  /**
   * angular HttpClient
   */
  http: HttpClient;
  /**
   * Constructor
   * @param {HttpClient} http HttpClient reference
   */
  constructor(http: HttpClient) {
    this.http = http;
  }

  getData(url: string) {
    return this.http.get(url, { responseType: 'json' })
      .pipe(
        map(res => {
          const result = {
            responseCode: 'OK'
          };
          result['result'] = get(res, 'result') || res;
          return result;
        })
      );
  }
}

results matching ""

    No results matching ""