here is my Http requests
in getAllUserData() i would like this.getAnXSRfToken() to finish exe before proceeding with the http request;
getAllUserData() {
//get XSRF token
this.getAnXSRfToken();
return this.http
.post<User[]>('http://localhost:8080/user/get-all-users-post', null, {
observe: 'response',
withCredentials: true,
})
.subscribe({
next: (array) => {
this.allUsersData.next(array.body);
},
error: (e) => {
console.log(e);
},
});
}
here is the this.getAnXSRfToken() method
getAnXSRfToken() {
return this.http
.post<{
parameterName: string;
headerName: string;
token: string;
}>('http://localhost:8080/user/getXSRfToken', null)
.subscribe({
next: (tokenData) => {
console.log('REQ --- token ---generated ');
console.log(tokenData.token);
this.XSRF_TOKEN.next(tokenData.token);
},
error: (e) => console.log(e),
});
}
New contributor
Mathew Francis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.