javascript – Bot Framework V4 – TypeError:无法对已撤销的代理执行’get’

我正在尝试对存储用户知识文章的数据库进行休息查询,并根据用户搜索的内容返回结果数组.每当我尝试搜索时,我得到:

“TypeError: Cannot perform ‘get’ on a proxy that has been revoked”

我已经尝试将其添加到如图所示的异步但我仍然得到相同的错误.知道我做错了什么吗?

const Response = async (turnContext) => {
    if (turnContext.activity.value.choice === 'feedbackProvider') {
        try {
            const feedbackBody = turnContext.activity.value.feedbackBody;
            const feedbackEmail = turnContext.activity.value.feedbackEmail;
            storage.write(feedbackBody, feedbackEmail);
            await turnContext.sendActivity(`Feedback Sent`);
        } catch (err) {
            console.log('fetch failed', err);
        }
    } else if (turnContext.activity.value.choice === 'issueRaiser') {
        try {
            const bugTitle = turnContext.activity.value.issueTitle;
            const bugDesc = turnContext.activity.value.issueDescription;
            const bugEmail = turnContext.activity.value.issueEmail;
            const request = require('request');
            request({
                method: 'Post',
                uri: `<uri>issues?title=${ bugTitle }&description=${ bugDesc } ${ bugEmail }&labels=bug`,
                json: true,
                headers: {
                    'Private-Token': '<token>'
                }
            });
            turnContext.sendActivity(`Issue Raised`);
        } catch (err) {
            console.log('fetch failed', err);
        }
    } else if (turnContext.activity.value.choice === 'knowledgeBaseSearch') {
        try {
            const knowledgeBaseTopic = turnContext.activity.value.knowledgeBaseTopic;
            request({
                url: process.env.SN_KB_URL + knowledgeBaseTopic,
                json: true,
                auth: {
                    'username': process.env.Ticket_User,
                    'password': process.env.Ticket_Key
                }
            }, async (error, response, body) => {
                try {
                    var stuff = [];
                    for (var i = 0, len = body.result.length; i < len; i++) {
                        stuff.push(
                            CardFactory.heroCard(body.result[i].short_description, ['imageUrl1'], [`${ process.env.SN_KB_Resp_URl }${ body.result[i].number }`])

                        );
                    }
                    let messageWithCarouselOfCards = MessageFactory.carousel(stuff);
                    await turnContext.sendActivity(messageWithCarouselOfCards);
                } catch (err) {
                    console.log(error);
                }
            });
        } catch (err) {
            console.log('fetch failed', err);
        }
    }
};

完整错误消息:

TypeError: Cannot perform 'get' on a proxy that has been revoked
cardMiddleware.js:35
    at Request.request [as _callback] (c:\Bots\sdk4-2\skills\cardMiddleware.js:35:45)
    at Request.self.callback (c:\Bots\sdk4-2\node_modules\request\request.js:186:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (c:\Bots\sdk4-2\node_modules\request\request.js:1163:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (c:\Bots\sdk4-2\node_modules\request\request.js:1085:12)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)

从论坛上的帖子中我得知我使用的是一个不支持Promises的请求模块,我相信这会导致我的错误.我现在开始使用Axios来满足我的要求,如下所示;

try {
    return await axios.get(process.env.SN_KB_URL + knowledgeBaseTopic, {
        headers: {
          auth: {
          username: process.env.Ticket_User,
          password: process.env.Ticket_Key
        }
      }
    })
  }

但是现在当我运行请求时,我收到401’未授权’错误,我不确定我的请求有什么问题.

最佳答案 出现此问题的原因是我使用的是不支持promises的请求模块.将我的请求模块更改为支持承诺(我通过使用
this article发现的)解决了问题.

点赞