On a client in my Phoenix application in an ajax callback I have this:
jResp = JSON.parse(xhr.responseText);
From a server I’m returning this:
# after a model has been inserted ....
put_status(conn, :no_content) |> json(%{})
On a client it throws an exception “Unexpected end of JSON input”
I’ve tried other things also:
put_status(conn, :no_content) |> json(nil)
put_status(conn, :no_content) |> json("")
and still it got passed to a client as an empty string which wasn’t valid json.
What should I return from a server as empty json?