Describe the bug
api returns invalid json when reporting postcode errors, and possibly others.
To Reproduce
- Navigate to https://www.openaustralia.org.au/api/key to obtain your API key
- Navigate to https://www.openaustralia.org.au/api/getDivisions?output=js&key=[KEY]&postcode=0100 (Replacing
[KEY] with your key)
Expected behavior
It should produce valid JSON output:
{"error":"Unknown postcode"}
Screenshots/Output
It produces invalid JSON output:
{"error":"Unknown postcode"}{}
Additional context
Its likely that api_error is being called without an exit to stop a following api_output being called. I noticed a number of places where this problem was present when investigating:
Not a problem everywhere, for example:
https://test.openaustralia.org.au/api/getDivisions?output=js&key=BADKEY&postcode=3000 works as expected
produces a valid json error response:
{"error":"Invalid API key."}
Describe the bug
api returns invalid json when reporting postcode errors, and possibly others.
To Reproduce
[KEY]with your key)Expected behavior
It should produce valid JSON output:
{"error":"Unknown postcode"}Screenshots/Output
It produces invalid JSON output:
{"error":"Unknown postcode"}{}Additional context
Its likely that api_error is being called without an exit to stop a following api_output being called. I noticed a number of places where this problem was present when investigating:
Not a problem everywhere, for example:
https://test.openaustralia.org.au/api/getDivisions?output=js&key=BADKEY&postcode=3000 works as expected
produces a valid json error response:
{"error":"Invalid API key."}