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

API Response Format #109

Closed
jaonoctus opened this issue Jan 13, 2017 · 3 comments
Closed

API Response Format #109

jaonoctus opened this issue Jan 13, 2017 · 3 comments

Comments

@jaonoctus
Copy link
Contributor

jaonoctus commented Jan 13, 2017

Would be nice if all of spa-starter-kit's REST API responses conform to the JSend Specification.

This means that every response will have a status and a data field in the JSON response. The status field will give either a success or fail. In the case of a success, the data will contain the requested data. In the case of a fail, the data will contain error messages.

For example, in the case of a bad request:

{
  "status": "fail",
  "data": {
    "errors": [
      { "name": "title", "message": "cannot be this ridiculous" },
      { "name": "description", "message": "must be provided" }       
    ]
  }
}

Here is an example of a successful request of a public profile:

{
  "status": "success",
  "data": {
    "id": 1,
    "email": "spa-starter-kit@codecasts.rocks"
  }
}
@vedovelli
Copy link
Contributor

@jaonoctus Thanks for the suggestion! Very welcome.

@flyingluscas would you like to comment on this?

@flyingluscas
Copy link
Collaborator

@jaonoctus Thanks for the suggestion, at this moment we have a similar structure, except we dont have a status field, I didn't think it was needed because we are using the http status codes to know if there was any errors or not, that way we always have to use the right status codes when returning a response, but what do you think @vedovelli ?

@vedovelli
Copy link
Contributor

@jaonoctus @flyingluscas If we have something in place, I'd suggest leave it as it is. Specially because a package was suggested to implement the idea. Thanks guy, I'm closing this issue.

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

No branches or pull requests

3 participants