使用 ibm watson 在聊天机器人中发送获取请求时如何解决错误?
How to solve an error while sending a get request in chatbot using ibm watson?
当我向 postman 发送 get 请求时,会话 ID 没有生成,而是进入 catch 块并显示发生错误,请帮我解决这个问题
const authenticator = new IamAuthenticator({
apikey: process.env.WA_ASSISTANT_APIKEY,
});
const assistant = new AssistantV2({
version: "2019-02-28",
authenticator: authenticator,
url: process.env.WA_ASSISTANT_APIKEY,
});
router.get("/session", async (req, res) => {
//if successfull
try{
const session = await assistant.createSession({
assistantId: process.env.WA_ASSISTANT_ID,
});
res.json(session["result"]);
//error
}catch(err){
res.send("An Error occured while processiong your request!");
console.log(err);
}
})
This is the code
Error
该错误表明您的应用正在尝试连接到本地主机上的 Watson Assistant。我怀疑错误是由于你的行 -
url: process.env.WA_ASSISTANT_APIKEY
APIKey
不太可能是 url。
当我向 postman 发送 get 请求时,会话 ID 没有生成,而是进入 catch 块并显示发生错误,请帮我解决这个问题
const authenticator = new IamAuthenticator({
apikey: process.env.WA_ASSISTANT_APIKEY,
});
const assistant = new AssistantV2({
version: "2019-02-28",
authenticator: authenticator,
url: process.env.WA_ASSISTANT_APIKEY,
});
router.get("/session", async (req, res) => {
//if successfull
try{
const session = await assistant.createSession({
assistantId: process.env.WA_ASSISTANT_ID,
});
res.json(session["result"]);
//error
}catch(err){
res.send("An Error occured while processiong your request!");
console.log(err);
}
})
This is the code Error
该错误表明您的应用正在尝试连接到本地主机上的 Watson Assistant。我怀疑错误是由于你的行 -
url: process.env.WA_ASSISTANT_APIKEY
APIKey
不太可能是 url。