Responses - mirkode/asana-code-challenge GitHub Wiki

You can have one out of multiple JSON responses.

Success

{
  "query": "Checkpoint Charlie",
  "coordinates": [
  {     
    "latitude": 52.5075459,
    "longitude": 13.3903685,
    "formatted": "Friedrichstraße 43-45, 10969 Berlin, Deutschland"
  },
  errors: []
}

No Results

{
    "query": "somethingterriblyinvalid",
    "coordinates": [],
    "errors": [
        {
            "provider": "Google",
            "message": "No results"
        }
    ]
}

Malformed Request

If you forget to append an address you will receive a 400 Bad Request.

{
  "errors": [
    {
      "message": "Please provide a geocodable search query (e.g. an address)"
    }
  ]
}

Other

All other errors, when happening on the external API side, should be looped through to the front-end via the GeoCodingError.
The error message follows the standard format above (ideally including on which provider's API it occurred).

{
  "errors": [
    {
      "provider": "PROVIDER_NAME",
      "errors": [{"message": "ERROR_MESSAGE"}]
    }
  ]
}