In my application, I am facing a challenge with implementing a method named loadAll
.
What I need to accomplish is to make calls to 2 different HTTP methods in order to load the necessary data.
Both of these methods return promises.
However, when I attempt to combine them into a single promise, I encounter an error.
loadAll() {
return new Promise((resolve, reject) => {
resolve(
this.getAllItem1ToConnect(),
this.getAllItem2ToConnect();
);
}
);
}
I am aware that this implementation is incorrect. How should I go about solving this issue?
Here is the method for loading Item1:
getAllItem1ToConnect() {
return this.http.get<Item1[]>(this.path + '/item').toPromise().then((res: Item1[]) => {
this.items1 = res;
});
}
Is there a way to merge the functionalities of getAllItem1ToConnect
and getAllItem2ToConnect
into a single promise?