src/app/modules/dashboard/services/usage/usage.service.ts
constructor(http: HttpClient)
|
Constructor
Parameters :
|
getData |
getData(url: string)
|
Returns:
void
|
http |
http: |
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;
})
);
}
}