In loopback 3 When i implement async/await in the before save Operation hook
Entry.observe('before save', async (ctx, next) =>{
if(ctx.instance.images){
Entry.upload(ctx.instance.images[0].src).then(data => {
ctx.instance.image = data;
});
}
});
the console print this error
(node:29323) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Callback was already called.
(node:29323) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
How can i get rid of this issue!?
PS. i cant figure out where's that promise, and this message disappear once i remove the async/await.
via dyaa
No comments:
Post a Comment