Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
What is the difference between a normal function call and function returning promise and function returning observable and when and where we can use promise or observable??
difference between Http and httpclient??

JavaScript
getUserDataFiltered(searchText: string, pageNumber: number = 0, pageSize: number = 0, sortColumn: string = "", sortDirection: string = "", token: string) {
    return this.http.get(Constants.API_URL + 'admin/getUserData.php?searchText=' + searchText + '&pageNo=' + pageNumber + '&pageSize='
      + pageSize + "&sortColumn=" + sortColumn + "&sortDirection=" + sortDirection + '&token=' + token)
      .pipe(map(res => res.json()));
  } 

  deleteUser(adminLogin: string): Promise<string> {
    return this.http.post(Constants.API_URL + 'admin/deleteUser.php', adminLogin, this.options).toPromise()
      .then(this.extractData)
      .catch(this.handleErrorPromise);
  }

  readPolicies(): Observable<Policy[]>{
    return this.httpClient.get<Policy[]>('http://127.0.0.1/API/Policy/read.php');
  }


What I have tried:

I tried to google it and get the various answer on it but not statifed to any answer.
Posted
Updated 26-Sep-19 9:53am
v3

1 solution

They are both defined inside the Component that you are currently viewing, if you would just view their definition you will understand what they are. Also, Angular components have a great amount of offline documentation, so if you would just hover over the type (HttpClientModule, for instance) you will be provided with a complete documentation and use case of the Component... Which I recommend that you do for the next Component or Service that you want to learn more about. :-)

Read this[^], and you can understand what HttpClientModule was the latest update to Angular ecosystem, making HttpModule older.

See this too: Angular Http[^].
Angular - Http vs HttpClient[^]

One more thing, please use either one of them as it will cause version and API conflicts later on in the project. So, make a choice and remove the HttpModule (this.http) from the project and use the latest HttpClientModule.
 
Share this answer
 
v2
Comments
Akshay malvankar 27-Sep-19 12:36pm    
what about following question-answer??

What is the difference between a normal function call and function returning promise and function returning observable and when and where we can use promise or observable?
Afzaal Ahmad Zeeshan 27-Sep-19 16:38pm    
That is for a new question thread. :-)

Create a new thread, and we can answer these there. But in most cases, you can simply Google that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900