i want to make a post resquest using angular 5, but it gives me an error : here is the code :
service.ts
import { Injectable } from \'@angular/core\'
try using this in your service.ts
import {Headers} from 'angular2/http';
var headers = new Headers();
headers.append(headerName, value);
addUser(user : User){
return this.http.post(this._baseUrl + '/API/identity/user',user,{ headers: headers}).map((response: Response) =>{
console.log (response.json());
})
}
here you need to send user interface to HTTP post. and map your response.
in ts file
createUser(){
this.dataService.addUser(this.user2).subscribe(data => {alert("Succesfully Added Product details")},Error => {alert("failed while adding product details")})
}