rddill-IBM / ZeroToCognitive

repository for the Zero to Cognitive Tutorial Series on YouTube
29 stars 632 forks source link

throwing this error #7

Open 10sp opened 5 years ago

10sp commented 5 years ago

/home/shiv/watsonworkspace/ZeroToCognitive/Chapter03/node_modules/express/lib/router/route.js:202 throw new Error(msg); ^

Error: Route.get() requires a callback function but got a [object Undefined] at Route.(anonymous function) [as get] (/home/shiv/watsonworkspace/ZeroToCognitive/Chapter03/node_modules/express/lib/router/route.js:202:15) at Function.proto.(anonymous function) [as get] (/home/shiv/watsonworkspace/ZeroToCognitive/Chapter03/node_modules/express/lib/router/index.js:510:19) at Object. (/home/shiv/watsonworkspace/ZeroToCognitive/Chapter03/controller/restapi/router.js:7:8) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18)

rhpoon commented 5 years ago

Error: Route.get() requires a callback function but got a [object Undefined]

I got the same error (although i can invoke the index.htm in HTML subfolder) Since router.js has (as shown in the open issue) var speech_to_text = require('./features/speech_to_text');

then in speech_to_text,js:

........................................................... var extend = require('extend'); var watson = require('watson-developer-cloud'); var vcapServices = require('vcap_services'); var config = require('../../env.json');

exports.token = function(req, res) {

} ........................................................................

so would this function(req, res) undefined??


Finally I checked out (as shown in error messages above), ZeroToCognitive/Chapter03/controller/restapi/router.js:7:8)

router.get('/api/speech-to-text/token*',speech_to_text.stt_token);

speech_to_text.stt_token should just be: speech_to_text.token (in speech_to_text function, only exports.token is defined, no stt_token!)

I get to spend extra 1 day in learning node.js and follow the codes!

rhpoon commented 5 years ago

Following the speech_to_text_complete.js in the answer folder, indeed it uses:

exports.stt_token = function(req, res) {.....................

so follow the speech_to_text_complete.js should also be fine as most of the rest of codes use "stt_token"