Check out this code snippet:
const reportModules = [
{ url: '', params: { to: format(TODAY, DATE_FORMAT).toString(), from: format(TODAY, DATE_FORMAT).toString() } },
{
url: 'application1',
params: { to: format(TODAY, DATE_FORMAT).toString(), from: format(TODAY, DATE_FORMAT).toString() }
},
{
url: 'application2',
params: {
to: format(endOfWeek(TODAY), DATE_FORMAT).toString(),
from: format(startOfWeek(TODAY), DATE_FORMAT).toString()
}
},
{
url: 'application3',
params: {
to: format(endOfWeek(TODAY), DATE_FORMAT).toString(),
from: format(startOfWeek(TODAY), DATE_FORMAT).toString()
}
}
];
const promises = reportModules.map(
target =>
new Promise(resolve => {
this.notificationService
.getSummary(target.url, target.params)
.pipe(take(1))
.subscribe(
(result: Response) => {
resolve({ target, result });
},
(err: Error) => {
// return reject(err);
}
);
})
);
const observables: Observable<any>[] = promises;
merge(...observables).subscribe((results) => { ... }
Any thoughts on how to address the error message
let observables: Observable<any>[]
'observables' is declared but its value is never read.ts(6133)
Type 'Promise<{}>[]' is not assignable to type 'Observable<any>[]'.
Type 'Promise<{}>' is missing the following properties from type 'Observable<any>': _isScalar, source, operator, lift, and 6 more.ts(2322)
?
The main objective here is to make sequential calls to load data from different applications in order.
For instance, it starts with the call to 'application1' followed by 'application2', ensuring a step-by-step process for each application.