Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always return data #45

Open
wbashir opened this issue Apr 29, 2015 · 3 comments
Open

Always return data #45

wbashir opened this issue Apr 29, 2015 · 3 comments

Comments

@wbashir
Copy link

wbashir commented Apr 29, 2015

Is there a way to always return the data array instead of the traditional formatted status and data request like so:

"data": [
    {
      "courseCredits": 4,
      "name": "SEIS45",
      "courseCode": "SESI452",
      "description": "Great class",
      "_id": "4a3nYgGSKTvZtbc5u"
    }
  ]
@kahmali
Copy link
Owner

kahmali commented Apr 29, 2015

Unfortunately, the only way to alter the response in the collection routes at the moment is to override the individual collection endpoints, which is a terrible solution. The good news is that this is very high on my priority list, and will be resolved in the first update after the Iron Router dependency is removed. What you need is a hook that runs immediately before the response is returned in collection endpoints, allowing you to modify the default response. I'll also allow the default endpoints to be completely overridden, in case you want to do something completely different but want to keep things DRY. This is related to #42, #12 , and #18. I'll keep you posted on any progress.

@wbashir
Copy link
Author

wbashir commented Apr 29, 2015

Thanks for the quick response

@achirkof
Copy link

Hi @kahmali, @wbashir
I have more less same question. I want to receive only data without any status and data prefixes:

{
    "_id": "QjCjP2DwqHqZJq54f"
    "name": "item name",
    "createdBy": "BeNTtaupkj5JfpJcH",
    "createdAt": "2016-06-18T10:00:04.113Z",
    "isPrivate": false,
    "isDeleted": false
}

instead of

{
    "status": "success",
    "data": [
        {
            "_id": "QjCjP2DwqHqZJq54f"
            "name": "item name",
            "createdBy": "BeNTtaupkj5JfpJcH",
            "createdAt": "2016-06-18T10:00:04.113Z",
            "isPrivate": false,
            "isDeleted": false
        }
    ]
}

Maybe somebody have solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants