Im trying to consume a service in a Laravel (Backend) with Angular 2. I can doit without any problem if I doit with axios, but I need to doit with HttpClient
How can I translate this code:
const url = `${this.endPoint}/login`;
const urlCsrf = `${this.endPoint}/csrf-cookie`;
const body = { email, password };
axios.defaults.withCredentials = true;
axios.get(urlCsrf).then(() => {
axios.post(url, body).then((resp) => {
console.log(resp);
});
});
to something like this but that it works:
//this code dont work returns csrf error
this.http.get(urlCsrf).subscribe(() => {
this.http.post(url, body).subscribe((resp) => {
console.log(resp);
});
});