Skip to content

Empty data in the response #31

@pods13

Description

@pods13

Hi!
I'm facing a problem that request are returning empty data.
For example:
my mongodb collection:
{ "_id" : "1", "name" : "Moscow" }, { "_id" : "2", "name" : "London" }
cities resource:

'use strict';

const jsonApi = require('jsonapi-server'),
    Joi = jsonApi.Joi;

const MongoHandler = require('jsonapi-store-mongodb');

module.exports = {
    resource: 'cities',
    handlers: new MongoHandler({
        url: "mongodb://localhost:27017/data",
    }),
    attributes: {
        name: Joi.string(),
    }
};

After this request:
http://localhost:4000/cities
I am getting this:
{"jsonapi":{"version":"1.0"},"meta":{"page":{"offset":0,"limit":50,"total":2}},"links":{"self":"/cities"},"data":[],"included":[]}
For some reason total==2 but api isn't providing any data.
Maybe something is wrong with the structure of my collection?

Many thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions