Witam. Mam takie coś w Angularze:
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { NgForm } from '@angular/forms';
@Injectable()
export class AccountService {
constructor(private http: HttpClient) { }
logIn(form: NgForm): boolean {
const credentials = form.value as JSON;
let bool = false;
console.log(credentials);
this.http.post('https://localhost:44305/api/auth/login', credentials)
.subscribe(data => {
const token = (data as any).token;
localStorage.setItem('jwt', token);
bool = true;
}, err => {
bool = false;
});
return bool;
}
}
Dlaczego to zawsze zwraca mi false, nawet jeśli ten bool ustawię na true? Dzięki za odpowiedzi.