Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throwing this error #7

Open
10sp opened this issue Jan 13, 2019 · 2 comments
Open

throwing this error #7

10sp opened this issue Jan 13, 2019 · 2 comments

Comments

@10sp
Copy link

10sp commented Jan 13, 2019

/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
Copy link

rhpoon commented Mar 29, 2019

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
Copy link

rhpoon commented Apr 10, 2019

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants