Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade angular 4 to 7 http to httpclient

Currently, I am upgrading my Angular project4 using webpack to Angular7.
I stuck in one step

Switch from HttpModule and the Http service to HttpClientModule and the HttpClient service. HttpClient simplifies the default ergonomics (You don't need to map to json anymore) and now supports typed return values and interceptors.

About this step I need to replace

  • HttpModule => HttpClientModule
  • Http => HttpClient

    For updating from Http => HttpClient, are there any script to help like
    $rxjs-5-to-6-migrate -p src/tsconfig.app.json or we need to edit manually?
like image 676
SpringKhmer Avatar asked Mar 04 '23 21:03

SpringKhmer


1 Answers

just change your imports from HttpModule to HttpClientModule and Http to HttpClient

import {HttpClientModule} from '@angular/common/http'
import {HttpClient} from '@angular/common/http'
like image 129
Derviş Kayımbaşıoğlu Avatar answered Mar 15 '23 23:03

Derviş Kayımbaşıoğlu