I'm having trouble saving an item to local storage when receiving a 200 response from the backend. It seems like the request status is not being recognized properly.
options = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Authorization': 'Bearer '+localStorage.getItem("access_token")
}),
observe: "response", // ensuring full response is displayed
responseType: "json"
};
constructor(private http: HttpClient, private router: Router) {
}
authenticate(url, data, options) {
this.http.post(environment.getBaseAddress() +url+'/', data, options).subscribe((data:any) => {
if (data.status == 200) {
localStorage.setItem("access_token", data['access_token']);
console.log(data.status)
}
else this.router.navigateByUrl('something-else');
})
}