mongo-rest
mongo-rest copied to clipboard
Can't return JSON
With the following code
var MongoRest = require('mongo-rest')
, mongoRest = new MongoRest(app, {
urlRoot: '/api/',
pathPrefix: "",
pathSuffix: ""
});
var Article = mongoose.model('Article');
mongoRest.addResource(Article, {
sort: "title",
viewPrefix: "api/",
viewSuffix: "",
enableXhr: true,
singleView: true
});
and the HTTP request:
GET /api/article
Accept: application/json
I get Error: Failed to lookup view "resource_articles" and a 500 response code
There are two problems:
- It doesn't return a JSON response but tries to response with HTML
-
viewPrefixhas no effect? Why would the error message says it cannot findresource_articles? The prefix does not contain resource_
Are you still experiencing this problem? Your config looks fine at first glance... Don't know what the problem could be.