Migrate @angular/http to @angular/common/http
ProprietaryPorts the @angular/http API that @angular/common/http replaces: Http, Headers, HttpModule, JsonpModule and QueryEncoder become HttpClient, HttpHeaders, HttpClientModule, HttpClientJsonpModule and HttpUrlEncodingCodec, new RequestOptions({...}) becomes the options object HttpClient takes, ResponseContentType.Blob becomes 'blob', and the map that HttpClient makes redundant is dropped. Http.request takes the method first, and every other request asks for its body as text, which is what Http handed back. URLSearchParams, the backends, the XSRF strategies and @angular/http/testing have no equivalent of the same shape, so they are flagged for a hand migration instead. The dependency is dropped either way, since no release of it resolves against Angular 8 or later: its last release pins @angular/core to an exact 7.x, so keeping it leaves a tree npm refuses to install, while dropping it turns whatever is left to migrate into a compile error on the lines that need the work.
org. openrewrite. angular. MigrateAngularHttpToCommonHttpmod run . --recipe= org. openrewrite. angular. MigrateAngularHttpToCommonHttpInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.
Recipe list
It runs these recipes, in this order.
- Migrate
@angular/httpto@angular/common/http(code changes) - org.openrewrite.javascript.RemoveDependency