meteor-rest
meteor-rest copied to clipboard
Uncaught ReferenceError: JsonRoutes is not defined
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.
You need to add the 'simple:json-routes' package to get access to that symbol. I should update the docs.
I have added both simple:json-routes & simple:rest. I saw underscore & webapp are dependencies so I added them too but the issue persists.
My app is built on Meteorchef Base using FlowRouter. I assume the JsonRoutes.add should go under the other Flowrouter directives?