2

Above code was written in intellij IDEA trying to implement Google Prediction API.

        var prediction= require('../googleapis/apis/prediction/v1.6');
        var params = {
            project: "693608054772",
            resource: {"id": "predictiondemo-1054", "storageDataLocation": "prediction3/language_id.txt"}
        };

        prediction.trainedmodels.insert(params, function (response) {
            if (err) {
                console.log("response occured:", response);
            }

        });

And Error that comes out is the following:

        /usr/local/bin/node predictionbhola.js
        /home/bhola/projects/nodejs/applane/node_modules/MyTests/predictionbhola.js:8
        prediction.trainedmodels.insert(params, function (response) {
                                ^
        TypeError: Cannot read property 'insert' of undefined
            at Object.<anonymous> (/home/bhola/projects/nodejs/applane/node_modules/MyTests/predictionbhola.js:8:25)
            at Module._compile (module.js:460:26)
            at Object.Module._extensions..js (module.js:478:10)
            at Module.load (module.js:355:32)
            at Function.Module._load (module.js:310:12)
            at Function.Module.runMain (module.js:501:10)
            at startup (node.js:129:16)
            at node.js:814:3

Process finished with exit code 1.

halfer
  • 19,824
  • 17
  • 99
  • 186
jones
  • 21
  • 1
  • What api client are you using? It's not obvious from the require statement, exactly. – Nick Sep 08 '15 at 16:33
  • What's happening is that the `prediction` object doesn't have a property "trainedmodels", so it comes up as `undefined`, and `undefined` doesn't have a property `insert`, clearly, so it throws the error. Either the string "trainedmodels" is wrong, or it's correct but hasn't been populated onto the "prediction" object, because of some missed init step. – Nick Sep 08 '15 at 16:35

0 Answers0