node.js - 我按照 Watson Tone 分析器的 api 文档无济于事 - 无法连接两个端点
问题描述
我有一个 Watson Tone 云服务启动并运行,我正在尝试将它链接到我的 index.js 文件。但是它似乎不想连接。
下面的代码:
const ToneAnalyzerV3 = require('watson-developer-cloud/tone-analyzer/v3');
const toneAnalyzer = new ToneAnalyzerV3({
version: '2017-09-21',
iam_apikey: 'omoNirDx1MUQwCdlHTQ-5Fxklx2_c0dUVAyMFIItFLty',
url: 'http://watson-row-analyser.eu-gb.cf.appdomain.cloud/#'
});
const text =
'Team, I know that times are tough! Product ' +
'sales have been disappointing for the past three ' +
'quarters. We have a competitive product, but we ' +
'need to do a better job of selling it!';
const toneParams = {
tone_input: { text: text },
content_type: 'application/json'
};
toneAnalyzer
.tone(toneParams)
.then((toneAnalysis) => {
console.log(JSON.stringify(toneAnalysis, null, 2));
})
.catch((err) => {
console.log('error:', err);
});
当前错误代码:
Marcs-MacBook-Pro:npm-global marcwatts$ node index1.js
error: { Not Found: Not Found
at formatError (/Users/marcwatts/Desktop/mxw817/DBTestApp/npm-global/node_modules/watson-developer-cloud/node_modules/ibm-cloud-sdk-core/lib/requestwrapper.js:111:17)
at /Users/marcwatts/Desktop/mxw817/DBTestApp/npm-global/node_modules/watson-developer-cloud/node_modules/ibm-cloud-sdk-core/lib/requestwrapper.js:259:19
at process._tickCallback (internal/process/next_tick.js:68:7)
name: 'Not Found',
code: 404,
message: 'Not Found',
body:
'"<!DOCTYPE html>\\n<html lang=\\"en\\">\\n<head>\\n<meta charset=\\"utf-8\\">\\n<title>Error</title>\\n</head>\\n<body>\\n<pre>Cannot POST /</pre>\\n</body>\\n</html>\\n"',
headers:
{ 'x-backside-transport': 'FAIL FAIL',
connection: 'close',
'transfer-encoding': 'chunked',
'content-security-policy': 'default-src \'none\'',
'content-type': 'text/html; charset=utf-8',
date: 'Sat, 06 Jul 2019 15:32:34 GMT',
'x-content-type-options': 'nosniff',
'x-powered-by': 'Express',
'x-global-transaction-id': 'ba9308f85d20bf12a70673ff' } }
Watson 的 api 链接:
https://cloud.ibm.com/apidocs/tone-analyzer?code=node
代码 404 表示未找到。请求的项目或参数不存在。我错过了什么?
解决方案
推荐阅读
- c++ - 变量 z 不能从不同的函数访问变量 x
- angular - 使用 ViewContainerRef 测试角度指令
- c++ - 与 CreateNamedPipe 重叠的 CreateProcess 标准输出
- reactjs - 设置 Firebase 身份验证时遇到问题
- azure-data-explorer - 动态查询 ADX 表名
- python - 根据另一列中的相同值组合熊猫数据框列中的文本值
- python - 尝试检查我的数据框列中的值是否低于 0 时收到 KeyError:0
- thinkscript - 当我尝试创建计数器时,为什么 thinkscript 会抛出这些问题?
- python - 查找所有可以从字母列表中组成的英语单词,使用每个字母的次数不超过它在列表中出现的次数
- html - 在 Google Optimize 中居中 div 类