gpt4 book ai didi

javascript - "No response has been set. Is this being used in an async call that was not returned as a promise to the intent handler?"使用 js

转载 作者:行者123 更新时间:2023-11-30 14:25:18 26 4
gpt4 key购买 nike

这是生成错误的代码,此意图在被调用时生成的完整响应是“未设置任何响应。这是在异步调用中使用的,但未作为对意图处理程序的 promise 返回?”我应该怎么做才能纠正它?

app.intent('getCrypto', (conv,{crypto="ethereum",cryptoactions="price"}) =>{
fetch('https://api.coinmarketcap.com/v1/ticker/').then(response => {
return response.json();
}).then(data => {
for (let i = 0; i < data.length - 1; i++) {
if (data[i].id === "bitcoin")
conv.data.price=data[i].price_usd;
conv.ask(`${conv.data.price} is the current value of ${crypto}`);
return response.json();
}

}).catch(err => {
return conv.ask(`${cryptoactions} of ${crypto} is not available. Would you like to know about another one?`);
});
});

最佳答案

错误消息描述了确切的问题“这是在未作为对意图处理程序的 promise 返回的异步调用中使用的吗?”

您应该从您的意图处理程序返回一个异步调用。因此,在调用 fetch 之前添加一个 return 应该可以解决这个问题。

关于javascript - "No response has been set. Is this being used in an async call that was not returned as a promise to the intent handler?"使用 js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52044368/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com