openSenseMap-API icon indicating copy to clipboard operation
openSenseMap-API copied to clipboard

Unify response messages

Open mpfeil opened this issue 8 years ago • 3 comments

Unify response message format to:

{
    code: "", // e.g. NotAuthorized or NotFound (restify errors) , Ok or Created for 2xx responses!
    message: "" // e.g. ApiKey valid or box data
}

mpfeil avatar Nov 02 '16 13:11 mpfeil

What is your opinion on methods which respond with data?

For example /boxes//data/ currently responds with [{"value":2,"createdAt":"<date>"},{"value":4,"createdAt":"<date>"}...]

New would be: {"code":"Ok","data":[...]}

ubergesundheit avatar Nov 02 '16 13:11 ubergesundheit

isn't the error/success code already represented in the HTTP Statuscode through restify?

noerw avatar Nov 02 '16 13:11 noerw

@noerw yes the http status code is always there.

The included restify errors are formatted like {code:"",message:""} For unification we will wrap all json responses like this..

ubergesundheit avatar Nov 02 '16 13:11 ubergesundheit