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

Uncaught ReferenceError: JsonRoutes is not defined

Open xen88 opened this issue 9 years ago • 3 comments

I get this error When adding CORS support as instructed in the documentation:

// Enable cross origin requests for all endpoints JsonRoutes.setResponseHeaders({ "Cache-Control": "no-store", "Pragma": "no-cache", "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, PUT, POST, DELETE, OPTIONS", "Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With" });

or when I add JsonRoutes:

JsonRoutes.add("get", "/players/:id", function (req, res, next) {
  var id = req.params.id;

  JsonRoutes.sendResult(res, {
    data: Players.findOne(id)
  });
});

I am using FlowRouter.

xen88 avatar Jan 18 '16 04:01 xen88

You need to add the 'simple:json-routes' package to get access to that symbol. I should update the docs.

stubailo avatar Jan 18 '16 05:01 stubailo

I have added both simple:json-routes & simple:rest. I saw underscore & webapp are dependencies so I added them too but the issue persists.

xen88 avatar Jan 18 '16 05:01 xen88

My app is built on Meteorchef Base using FlowRouter. I assume the JsonRoutes.add should go under the other Flowrouter directives?

xen88 avatar Jan 18 '16 05:01 xen88