I cannot understand what I am doing wrong, and why this error "res.json is not a function"
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { map } from 'rxjs/operators';
@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:3000/account/reg',
user,
{headers: headers}).pipe(map((res: any) => res.json()));
}
}
Aucun commentaire:
Enregistrer un commentaire