meteor-restivus icon indicating copy to clipboard operation
meteor-restivus copied to clipboard

Error in using AddCollection in Meteor.user

Open abelkuruvilla opened this issue 8 years ago • 4 comments

When I try to add Meteor.users for REST authentication, my app is crashing.

I used the code found in the documentation code itself:

Api.addCollection(Meteor.users, { excludedEndpoints: ['getAll', 'put'], routeOptions: { authRequired: true }, endpoints: { post: { authRequired: false }, delete: { roleRequired: 'admin' } } });

The error I get is:

/Users/abel/.meteor/packages/meteor-tool/.1.4.2_6.1y6rhi4++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280 throw(ex); ^

TypeError: Cannot read property 'call' of undefined at Restivus. (packages/nimble_restivus/lib/restivus.coffee:126:45) at Array.forEach (native) at Function..each..forEach (packages/underscore.js:139:11) at Restivus.Assets.Restivus.Restivus.addCollection (packages/nimble_restivus/lib/restivus.coffee:120:9) at meteorInstall.imports.api.privateEventApiTest.js (imports/api/privateEventApiTest.js:31:6) at fileEvaluate (packages/modules-runtime.js:188:9) at Module.require (packages/modules-runtime.js:111:16) at Module.Mp.import (/Users/abel/.meteor/packages/modules/.0.7.7.yjn28g++os+web.browser+web.cordova/npm/node_modules/reify/lib/runtime.js:70:16) at meteorInstall.server.main.js (server/main.js:1:1) at fileEvaluate (packages/modules-runtime.js:188:9) Exited with code: 1 Your application is crashing. Waiting for file change.

abelkuruvilla avatar Feb 15 '17 10:02 abelkuruvilla

Try this: Api.addCollection(Meteor.users, { excludedEndpoints: [ 'put','post','delete','patch'], routeOptions: { authRequired: false } });

Timsor avatar Feb 17 '17 18:02 Timsor

Am getting the same error with 0.8.12 but its okay with 0.8.11.

AntonyThorpe avatar Mar 09 '17 05:03 AntonyThorpe

The example above works but if you remove 'patch' from excludedEndpoints array

Api.addCollection(Meteor.users, {
  excludedEndpoints: [ 'put','post','delete'],
  routeOptions: {
    authRequired: false
  }
});

then the error occurs. Mmmm, I think patch might need a patch (sorry, couldn't hold that one back).

AntonyThorpe avatar Mar 13 '17 06:03 AntonyThorpe

Found it - the _userCollectionEndpoints object doesn't have a patch method.

AntonyThorpe avatar Mar 14 '17 06:03 AntonyThorpe