Http Post in Angular

Asked

Viewed 352 times

-1

Guys, I’m trying to do an http post to send a json to the server but it’s giving an error. My code is as follows

the Imports

import { Component, OnInit } from '@angular/core';
import { FormGroup, FormControl, FormBuilder } from "@angular/forms";
import { Http } from '@angular/http';
import { map } from 'rxjs/operators';

and here’s my http post

  onSubmit() {
console.log(this.formulario.value)

this.http
.post('https://httpbin.org/post', JSON.stringify(this.formulario.value)).pipe(
.map(res => res))
.subscribe(dados => console.log(dados))

}

E fica constando esse erro :(, alguém poderia dar uma luz ?

1 answer

0


If you use pipe do not need point before map.

.post('https://httpbin.org/post', JSON.stringify(this.formulario.value)).pipe
(map(res => res))
  • Thanks man, it was killing me here hahah! Thanks!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.