parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.93k stars 4.78k forks source link

TypeError: undefined is not a function. Local setup. #519

Closed myyellowshoe closed 8 years ago

myyellowshoe commented 8 years ago

Getting an interesting when running parse-server locally on my mac. It only seams to happen locally, when I deploy it to heroku it works fine. I'm using heroku and mongo lab for my setup production wise.

So for example, when I run a simple query on my local server like so:

curl -X GET -H "X-Parse-Application-Id: asdf" -H "X-Parse-REST-API-Key: asdf" http://127.0.0.1:1337/parse/classes/tasks

I get the following.

Uncaught internal server error. [TypeError: undefined is not a function] TypeError: undefined is not a function
    at handleFind (/Users/administrator/Dropbox/Development/priorigami_server/node_modules/parse-server/lib/classes.js:15:21)
    at /Users/administrator/Dropbox/Development/priorigami_server/node_modules/parse-server/lib/PromiseRouter.js:138:7
    at Layer.handle [as handle_request] (/Users/administrator/Dropbox/Development/priorigami_server/node_modules/parse-server/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/administrator/Dropbox/Development/priorigami_server/node_modules/parse-server/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/Users/administrator/Dropbox/Development/priorigami_server/node_modules/parse-server/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/administrator/Dropbox/Development/priorigami_server/node_modules/parse-server/node_modules/express/lib/router/layer.js:95:5)
    at /Users/administrator/Dropbox/Development/priorigami_server/node_modules/parse-server/node_modules/express/lib/router/index.js:277:22
    at param (/Users/administrator/Dropbox/Development/priorigami_server/node_modules/parse-server/node_modules/express/lib/router/index.js:349:14)
    at param (/Users/administrator/Dropbox/Development/priorigami_server/node_modules/parse-server/node_modules/express/lib/router/index.js:365:14)
    at Function.process_params (/Users/administrator/Dropbox/Development/priorigami_server/node_modules/parse-server/node_modules/express/lib/router/index.js:410:3)

Which is located at: lib/classes.js

function handleFind(req) {
  var body = Object.assign(req.body, req.query);
  var options = {};

What could be wrong with my local setup? Sign in seams to be working ok, but for some reason when I use find it explodes.

nitrag commented 8 years ago

Same error here. Fresh migration, fresh database. Using JS SDK so the appId key is in the body.

GET /1/classes/Activity { host: 'localhost:1337',
  'content-type': 'text/plain',
  'accept-language': 'en-us',
  'accept-encoding': 'gzip, deflate',
  connection: 'keep-alive',
  accept: '*/*',
  'user-agent': 'Appcelerator Titanium/5.1.1 (iPhone/9.2; iPhone OS; en_US;)',
  'content-length': '528',
  'x-titanium-id': 'ff9422b7-2258-4a97-9fff-8021dee1df65',
  'x-requested-with': 'XMLHttpRequest' } {
  "where": {
    "$or": [
      {
        "fromUser": {
          "__type": "Pointer",
          "className": "_User",
          "objectId": "15QSQgv93Z"
        }
      },
      {
        "toUser": {
          "__type": "Pointer",
          "className": "_User",
          "objectId": "15QSQgv93Z"
        }
      }
    ]
  },
  "include": "fromUser,toUser,Image,Park,Club,Trail",
  "limit": 15,
  "order": "-createdAt"
}
error: [TypeError: undefined is not a function]
Uncaught internal server error. [TypeError: undefined is not a function] TypeError: undefined is not a function
    at ClassesRouter.handleFind (/Users/ryan/Documents/Parse/parse-offroad-server/node_modules/parse-server/lib/Routers/ClassesRouter.js:36:25)
    at /Users/ryan/Documents/Parse/parse-offroad-server/node_modules/parse-server/lib/Routers/ClassesRouter.js:155:22
    at /Users/ryan/Documents/Parse/parse-offroad-server/node_modules/parse-server/lib/PromiseRouter.js:138:7
    at Layer.handle [as handle_request] (/Users/ryan/Documents/Parse/parse-offroad-server/node_modules/parse-server/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/ryan/Documents/Parse/parse-offroad-server/node_modules/parse-server/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/Users/ryan/Documents/Parse/parse-offroad-server/node_modules/parse-server/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/ryan/Documents/Parse/parse-offroad-server/node_modules/parse-server/node_modules/express/lib/router/layer.js:95:5)
    at /Users/ryan/Documents/Parse/parse-offroad-server/node_modules/parse-server/node_modules/express/lib/router/index.js:277:22
    at param (/Users/ryan/Documents/Parse/parse-offroad-server/node_modules/parse-server/node_modules/express/lib/router/index.js:349:14)
    at param (/Users/ryan/Documents/Parse/parse-offroad-server/node_modules/parse-server/node_modules/express/lib/router/index.js:365:14)
btate commented 8 years ago

What version of node are you on? I upgraded to 4.x and it fixed that.

nitrag commented 8 years ago

Yep that was it. Forgot I also used 0.12 and toggle back and forth. Thanks!

On Tue, Feb 23, 2016 at 5:49 PM, Brandon Tate notifications@github.com wrote:

What version of node are you on? I upgraded to 4.x and it fixed that.

— Reply to this email directly or view it on GitHub https://github.com/ParsePlatform/parse-server/issues/519#issuecomment-187949917 .