2016-09-05 37 views
0

我使用對話框服務有bluemix應用程序,我想包括使用文本到語音服務bluemix文本到語音服務:如何包括使用節點

var watson = require('watson-developer-cloud'); 
我index.js

我收到一個未定義的錯誤。

我已經嘗試在構建管道中添加npm install watson-developer-cloud,但它不起作用。我也嘗試了瀏覽。

+0

他們的文檔中有一個很好的例子,除了「undefined」之外,還有其他的錯誤可以幫助我們嗎?首先,你應該使用'var TextToSpeechV1 = require('watson-developer-cloud/text-to-speech/v1');' 'https://www.npmjs.com/package/watson-developer-cloud #text-to-speech –

+0

它說require是沒有定義的,我讀了我無法在jquery或客戶端使用require。我也查看了browserify – Johnson

回答

0

在你app.js聲明

var watson = require('watson-developer-cloud'); app.get('/test', function(req, res) { //call all req function here });

在你Index.js添加

$('#text_to speech').click(function(e){ 

$.ajax({ type: 'GET', data: { text: "text to speech" }, url: '/test' , success: function(response) { console.log('success'); } }); 
} 
+0

謝謝 - 事實證明,我試圖在客戶端內部執行require(watson)碼 – Johnson

0

不看更多的構建管道,很難看到你的npm install命令是否正確運行。我建議你添加沃森開發商雲的依存列表中你的package.json

+0

是的,我將npm watson-developer-cloud添加到了我的管道中,但它似乎沒有做任何事情來解決問題 – Johnson