Reputation: 848
I have this async function:
public promiseFunction = async (value: string): Promise<any> => {
myFunction.send(data).then(() => {
return 'result from promise';
})
.catch((error) => {
return `Error string: ${error}`
});
}
Then i call this function of this way:
await promiseFunction('testing function')
.then(function(val) {
console.log(`result of function: ${val}`);
reply(val);
});
How can I return a value of a promise?
Upvotes: 0
Views: 142
Reputation: 875
Without really knowing what you are asking for and where and how you are using that function, I'd like to state that you're probably using the async/await syntax wrongly.
When using await
you would normally do something like:
async function foo() {
var result = await promiseFunction('testing function');
console.log(result);
}
Upvotes: 1