问题
I am new to Angular and RxJS operators. I need help in one of the scenario in which I upload multiple documents at once in the backend (Rest API).
Processing the documents takes time in backend my my observable gets timeout in 2 minutes.
Now I am thinking of the solution in which I will send the post request to backend and will not wait for the response. And subscribe whenever response is ready by backend.
Please suggest if my approach is ok ? and how to achieve it in angular 8 with and Rxjs operators.
below is the my httpclient post method:
createNewVersion(formData: FormData) {
let payload = new HttpParams();
return this.httpClient
.post(endpoint, formData, { params: payload }).subscribe((response: boolean) => {
this.isLoading = false;
if (response != null)
this.observableVersion.next(true);
});
}
Currently I am facing timeout error after 2 minutes when response doesnt comes from backend that is why I have to change the logic.
Please help.
来源:https://stackoverflow.com/questions/64659213/send-httpclient-post-request-but-dont-wait-for-response-and-subscribe-when-backe