Created
November 21, 2019 22:25
-
-
Save senthilmpro/6a3293ecdb4c1e9cc6456ca606f602e0 to your computer and use it in GitHub Desktop.
async-await-es6-angular.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class AuthService { | |
httpClient : HttpClient; | |
constructor(httpClient : HttpClient) { | |
this.httpClient = httpClient; | |
} | |
// get data using ES6 await async in Angular 7/8/9 | |
async getData(url, postData){ | |
const data = await this.httpClient.post(url, postData).toPromise(); | |
console.log(data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment