Beginner in angular Problems with observable

0

I'm new to the angular development world and I'm having a simple problem but I can not solve it.

I started the project using angular cli 1.5.2, where angular using 5.0.0

I'm trying to do a simple api query with path in link , using postman with access to it.

I put the observable in the constructor of the page, but the code is simply ignored, does not make the request nor even shows it on the browser network.

Here are the only files I changed when I started the application with angular cli for sass.

Can you help me fulfill this request?

appComponent file

import { Component } from '@angular/core';
import { Http, Response, Headers } from '@angular/http';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})

export class AppComponent {
  title = 'app';

  constructor(private http:Http) {
    http.post('http://localhost:3333/app/users/login', { email: 'teste', password: 21323 })
    .map((response: Response) => {
        console.log('veio')
    });



  }

}

app.module file

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import 'rxjs/add/operator/map';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    HttpModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
    
asked by anonymous 21.11.2017 / 00:48

1 answer

0

Hello after searching more, and chatting with some friends, I discovered that the request was not being answered correctly, when exchanging map by subscribe the request started to work.

    
21.11.2017 / 02:55