I need to pass the token that comes to me from the database so that laravel lets me enter the content. Here I leave my code
import { Component } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {SessionStorageService} from 'ngx-webstorage';
import { Router } from '@angular/router';
import { NgForm } from '@angular/forms';
public sesion = false;
user: any = <any>{};
constructor(public _http:HttpClient,
public _local:SessionStorageService,
public _rutas:Router
) {
}
login(a:NgForm){
const url = 'http://localhost/api/public/login';
this._http.post(url,{
'username':this.user.username,
'password':this.user.password
}).subscribe(data => {
this.user = data;
this.sesion = true;
this._local.store('user',data);
this._rutas.navigate(['main']);
console.log('ha ido bien');
console.log(data);
}, error => {
console.log('error');
this.sesion = false;
});
}
This function returns the user with the data that happened to him from the html