I have post http request which sends large amount of data, and contains array which can be quite large. I am trying to split the request so instead sending one request which contains all of the data, I would like to send it in chunks.
// service.ts
saveRequest(request: AutomationChecklist) {
return this.http
.post(this.url + this.saveRequestUrl, request, this.options)
.map((response: Response) => {
return response.json();
});
}
// automationChecklist.ts
export class AutomationChecklist {
siteInformation: siteInformation;
orderInformation: OrderInformation;
requestInformation: RequestInformation;
contactInformation: ContactInformation;
installations: Installation[]; // save this separately, this one can be quite large
completedAutomation: number;
progress: number;
}
what can be the possible solution to handle this request? I have read about forkjoin rxjs but not sure if it will be suitable for this situation?
If you want to separate installations
you can do it using the concatMapTo
operator :
saveRequest(automations: AutomationChecklist, installations: Installation[]) {
return this.http
.post(this.url + this.saveRequestUrl, automations, this.options)
.pipe(concatMapTo(this.http.post(this.url + /*installations save url*/, installations, this.options)))
.map((response: Response) => {
return response.json();
});
}
Drawbacks of this solution:
It depends on what you want to do, if you accept inconcistency, it could be a good solution to lighten your request.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments