node.jsapigeeusergridapigee-baas

Usergrid node.js usergrid.init() error


I start to use apigee and I use the baas withe usergrid and the node.js sdk when I use my file in local and make http request there is no problems but when i try to upload the node.js file with :

apigeetool deployproxy -u USERNAME -p PASSWORD -o ORG -e test -n hello -d .

and try to make request I got the error

{"fault":{"faultstring":"Script node executed prematurely: TypeError: Cannot find function setPrototypeOf in object function Object() { [native code for Object.Object, arity=1] }\n.\nTypeError: Cannot find function setPrototypeOf in object function Object() { [native code for Object.Object, arity=1] }\n.\n    at \/organization\/environment\/api\/node_modules\/usergrid\/usergrid.js:29\n    at \/organization\/environment\/api\/app.js:28\n    at module.js:456\n    at module.js:474\n    at module.js:356\n    at module.js:312\n    at module.js:497\n    at startup (trireme.js:142)\n    at trireme.js:923\n","detail":{"errorcode":"scripts.node.runtime.ScriptExitedError"}}}

its seems to come from my app.js file, the line :

usergrid.init();

and more precisely from my usergrid.js file, the line

Object.setPrototypeOf(self, new UsergridClient(options))

thank you in advance and sorry for the bad english


Solution

  • I replaced

    usergrid.init();
    

    by

    var UsergridClient = require('./node_modules/usergrid/lib/client')
    var Usergrid = new UsergridClient
    ({
        "appId": "<my_appId>",
        "orgId": "<my_orgId>",
        "authMode": "<my_authMode>",
        "baseUrl": "<my_baseUrl>",
        "clientId": "<my_clientId>",
        "clientSecret": "<my_clientSecret>"
    })
    

    this way the usergrid.js is not executed and don't call the setPrototypeOf function