I want to insert a token into a cookie, but the issue is that the cookie is created before receiving the API response. How can I make sure to wait for the response before creating the cookie?
My Implementation:
getLogin() {
this._symfonyService.login(this.user,this.pass).subscribe(
data => {
this.results = data;
},
error => {
console.log("Error in HTTP Post Service");
},
() => {
console.log(this.results['token']);
if(this.results['token'] !== "") {
let token = this.results['token'];
this.deleteCookie("Cookieteste");
this.setCookie("Cookieteste", token, 1);
}
});
}