For questions directly related to the use of the Http service in Angular.
Questions tagged [angular2-http]
390 questions
                    
                    353
                    
            votes
                
                11 answers
            
        Is it necessary to unsubscribe from observables created by Http methods?
Do you need to unsubscribe from Angular 2 http calls to prevent memory leak?
 fetchFilm(index) {
        var sub = this._http.get(`http://example.com`)
            .map(result => result.json())
            .map(json => {
               …
         
    
    
        born2net
        
- 24,129
- 22
- 65
- 104
                    239
                    
            votes
                
                5 answers
            
        Difference between HttpModule and HttpClientModule
Which one is best to build a mock web service just for test purposes in Angular apps?
         
    
    
        Aiyoub A.
        
- 5,261
- 8
- 25
- 38
                    207
                    
            votes
                
                14 answers
            
        File Upload In Angular?
I know this is very a general question but I am failing to upload a file in Angular 2. 
I have tried 
1) http://valor-software.com/ng2-file-upload/ and 
2) http://ng2-uploader.com/home 
...but failed. Has anyone uploaded a file in Angular? What…
         
    
    
        heman123
        
- 3,009
- 4
- 24
- 37
                    180
                    
            votes
                
                3 answers
            
        Angular 2 http.post() is not sending the request
When I make a post request the angular 2 http is not sending this request
this.http.post(this.adminUsersControllerRoute, JSON.stringify(user), this.getRequestOptions())
the http post is not sent to the server but if I make the request like this…
         
    
    
        Nicu
        
- 3,476
- 4
- 23
- 43
                    177
                    
            votes
                
                3 answers
            
        Angular2: How to load data before rendering the component?
I am trying to load an event from my API before the component gets rendered. Currently I am using my API service which I call from the ngOnInit function of the component.  
My EventRegister component:
import {Component, OnInit, ElementRef} from…
         
    
    
        Tom Aalbers
        
- 4,574
- 5
- 29
- 51
                    116
                    
            votes
                
                7 answers
            
        Angular 2 - Routing - CanActivate work with Observable
I have an AuthGuard (used for routing) that implements CanActivate.
canActivate() {
    return this.loginService.isLoggedIn();
}
My problem is, that the CanActivate-result depends on a http-get-result - the LoginService returns an…
         
    
    
        Philipp
        
- 4,180
- 7
- 27
- 41
                    67
                    
            votes
                
                8 answers
            
        Angular: Cannot find a differ supporting object '[object Object]'
Im following this tutorial. On the way to get list of users from api.github Im getting error:  
Cannot find a differ supporting object '[object Object]'
I think its related to 
 
        - {{user | json}} …
 
    
    
        blackHawk
        
- 6,047
- 13
- 57
- 100
                    64
                    
            votes
                
                5 answers
            
        Angular - POST uploaded file
I'm using Angular, TypeScript to send a file, along with JSON Data to a server.
Below is my code:
import {Component, View, NgFor, FORM_DIRECTIVES, FormBuilder, ControlGroup} from 'angular2/angular2';
import {Http, Response, Headers} from…
         
    
    
        Kamal
        
- 1,476
- 1
- 13
- 21
                    60
                    
            votes
                
                3 answers
            
        angular 2 http withCredentials
I'm am trying to use withCredentials to send a cookie along to my service but can't find out how to implement it.
The docs say "If the server requires user credentials, we'll enable them in the request headers" With no examples.
I have tried several…
         
    
    
        Lindstrom
        
- 795
- 1
- 5
- 10
                    54
                    
            votes
                
                7 answers
            
        How to correctly set Http Request Header in Angular 2
I have an Ionic 2 application using Angular 2, which is sending an Http PUT to a ASP.NET Core API server. Here's the method I'm using to send the request:
public update(student: Student): Promise
{
    let headers = new Headers();
   … 
         
    
    
        rbasniak
        
- 4,484
- 11
- 51
- 100
                    53
                    
            votes
                
                9 answers
            
        Set base url for angular 2 http requests
I am trying to set base url for all my angular 2 http requests. Following is the basic set up for my application.
class HttpOptions extends BaseRequestOptions {
  url:string = "http://10.7.18.21:8080/api/";
}
bootstrap(AppComponent, [
 …
         
    
    
        TheKojuEffect
        
- 20,103
- 19
- 89
- 125
                    50
                    
            votes
                
                9 answers
            
        File Upload with Angular2 to REST API
Actually, I'm working on a Spring REST API with an interface coded in Angular 2.
My problem is I can't upload a file with Angular 2.
My Webresources in java is that : 
@RequestMapping(method = RequestMethod.POST, value = "/upload")
public String…
         
    
    
        Slater
        
- 817
- 2
- 10
- 16
                    47
                    
            votes
                
                14 answers
            
        Cannot find module './in-memory-data-service' in tour of heroes for Angular2
I am trying to work through the Angular2 tour of heroes app, and am running into bugs on the Http section of the tutorial.  
At first I was getting the error:
Cannot find module 'angular2-in-memory-web-api'
But fixed that using the information from…
         
    
    
        Jonathan Bechtel
        
- 3,497
- 4
- 43
- 73
                    44
                    
            votes
                
                13 answers
            
        How to use/import http module?
I've been playing with Angular 2 Quickstart.
How can I use/import http module in Angular 2?
I've looked at Angular 2 Todo's.js, but it doesn't use the http module.
I've added "ngHttp": "angular/http", to dependencies in package.json because I've…
         
    
    
        luthfianto
        
- 1,746
- 3
- 22
- 37
                    42
                    
            votes
                
                4 answers
            
        How do you POST a FormData object in Angular 2?
I need to upload a file and send some json along with it, I have this function:
POST_formData(url, data) {
        var headers = new Headers(), authtoken = localStorage.getItem('authtoken');
        if (authtoken) {
           …
         
    
    
        Sebastian Olsen
        
- 10,318
- 9
- 46
- 91