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

Can't return JSON

Open ads901119 opened this issue 12 years ago • 1 comments

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:

  1. It doesn't return a JSON response but tries to response with HTML
  2. viewPrefix has no effect? Why would the error message says it cannot find resource_articles? The prefix does not contain resource_

ads901119 avatar Aug 07 '13 09:08 ads901119

Are you still experiencing this problem? Your config looks fine at first glance... Don't know what the problem could be.

enyo avatar Aug 20 '13 14:08 enyo