I am trying to send the response back to chatbot emulator
from inside callback.
async getUserDetails(step){
console.log("inside get userdetaiuls modeiule")
this.userDBObject.password = step.result;
this.userDBMethod ( async function(response){
console.log("inside callback return");
console.log(response);
await step.context.sendActivity(response); // not able to do this step
return step.endDialog();
});
}
async userDBMethod(callback){
request.post('#',
{form:{key: 'hi'}}, function (error, response, body) {
callback("done");
});
}
The error which I'm getting is:
(node:17424) UnhandledPromiseRejectionWarning: TypeError: Cannot perform 'get' on a proxy that has been revoked at D:\LCI\Usecases\statementBalance\lionsbot-src\bot.js:384:32 at Request._callback (D:\LCI\Usecases\statementBalance\lionsbot-src\bot.js:410:17) at Request.self.callback (D:\LCI\Usecases\statementBalance\lionsbot-src\node_modules\request\request.js:185:22) at Request.emit (events.js:182:13) at Request.EventEmitter.emit (domain.js:442:20) at Request. (D:\LCI\Usecases\statementBalance\lionsbot-src\node_modules\request\request.js:1161:10) at Request.emit (events.js:182:13) at Request.EventEmitter.emit (domain.js:442:20) at IncomingMessage. (D:\LCI\Usecases\statementBalance\lionsbot-src\node_modules\request\request.js:1083:12) at Object.onceWrapper (events.js:273:13) (node:17424) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:17424) [DEP0018] 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.
So how can I use await inside callback to send response back to the user. Thanks !
try/catch
to catch errors thrown in the Promise? – CertainPerformance