I am posing the data on the server in angular with http post request and with rxjs but even after importing map property of rxjs this is giving an error.
import { Injectable } from '@angular/core';
import {HttpClient,HttpHeaders,HttpErrorResponse} from '@angular/common/http';
import {throwError } from 'rxjs';
import 'rxjs/add/operator/map';
@Injectable({
providedIn: 'root'
})
export class AuthService {
constructor(private http:HttpClient) { }
registerUser(user){
let headers = new HttpHeaders();
headers.append('content-type','application/json');
return this.http.post('http://localhost:8080/users/register',user,{headers:headers})
.map(response =>response.json())
.catch(this.errorHandler)
}
errorHandler(error:HttpErrorResponse){
return throwError(error.message||"Server not responding");
}
}
i even import map property like this:
import {map} from 'rxjs/add/operator';
Error:
Property 'map' does not exist on type 'Observable<Object>'
User is a object