I am looking to execute two HTTP requests, one GET and one POST, where the second request is based on the response from the first.
Here is the output from the initial GET call:
{
"weekNbr": "34-2017",
"startDate": "2017-09-16",
"endDate": "2017-09-22"
}
The response will be modified and used as the body for the subsequent POST request in this format:
{
"weekNbr": 34, (from initial response)
"year": 2017 (from initial response)
}
A possible solution involves utilizing RxJS operators to handle both requests within a single service:
http.get(url1).pipe(
map(perform manipulation)
).subscribe(
(newObject) => {
return http.post(url2, newObject);
}
);
It's worth noting that these calls need to be completed within a unified service. Any recommendations on specific rxjs operators for this task would be greatly appreciated.