`Http` is not found in "@angular/http"?


#1

I can’t import http in :

import {Headers, Response,Http } from "@angular/http";

image

When I let webstorm add http automatically - it adds :

  import {Http} from "@angular/http/src/http";

packages.json : http://jsbin.com/dopoloyego/edit?html,output

Global packages :

C:\temp\DevelopmentGroceries>npm -g list --depth=0
C:\Users\royin\AppData\Roaming\npm
+-- nativescript@3.3.0
+-- timeline-view@0.0.6
+-- typescript@2.6.1
+-- undefined@0.1.0
`-- webpack@3.8.1

Question :

Why can’t I import Http and how can I resolve this issue ?


#2

Hi @Royi_Namir . Have you imported NativeScriptHttpModule from nativescript-angular/http. You need to have nativescripthttp module before using it in services .For more references,please refer https://docs.nativescript.org/angular/code-samples/http


#3

Angular recommends that you use the HttpClient from @angular/common/http instead of Http. I believe they have a breaking change in 5.0 to remove it from @angular/http.

And do not ever trust auto importers.

@angular/http/src/http is not valid, the correct path is @angular/http.