Open alex-knowles opened 7 years ago
I support this.
Note: I made a minor change to the example JSON posted above.
Previously, the top-level JSON object was named "poems". I changed it to "data". This is the default name generated by Phoenix. It is trivial to change, but "data" is a good default because it is predictable and generic for client consumption.
Edit: I changed the example object name to "data" instead of "poems".
Requesting a poem index might return something like:
However, there is some conventional wisdom against returning top-level JSON arrays. Instead, clients should expect the server to return the array wrapped in an object. For example: