Reputation: 1905
I have a function that gets a bot's inventory on the Frontend
getBotInventory() {
this.socket.emit('get bot inv');
this.socket.on('bot inv', (botInventory) => {
return new Promise((resolve, reject) => {
if (botInventory.error) {
return reject(botInventory.error);
}
this.botInventory = botInventory;
resolve(botInventory);
});
});
}
As you can see, it returns a Promise.
When I try to call it
getBotInventory() {
this.userService.getBotInventory().then(botInv..)
}
I'm getting
error TS2339: Property 'then' does not exist on type 'void'.
Obviously it returns a Promise
. Can anyone point out where the problem is?
Upvotes: 3
Views: 4045
Reputation:
It may be obvious for you, but it isn't for me.
Look at your function, cleaned of callbacks.
getBotInventory() {
this.socket.emit('get bot inv');
this.socket.on('bot inv', (botInventory) => {...});
}
I don't see any return statement there !
Upvotes: 5