My constructor looks like this
constructor(postGameObj: SubmitGame, gamesService: GamesService) {
this.postGameObj = postGameObj;
this.gameService = gamesService;
}
and my attachLink function looks like this :
private attachLink(socialLink: SocialLink): Promise<any> {
return new Promise((resolve, reject) => {
this.gameService
.postSocialLink({
body
})
.subscribe(
(data) => {
resolve(data.data);
},
(error) => {
reject(new Error());
}
);
});
}
I'm saving some values to the gameSocials array of objects, but when I call Promise all :
await Promise.all(gameSocials.map(this.attachLink));
gameService is undefined :
When I console.log the gameService outside the Promise.all(), everything is fine. Also when I'm using the service object, it works normal.
What am I missing?