4 ms·
That isn't a pattern, that's a preference. It's one that seemed appealing to me at one time but that I now disagree with because it's unidiomatic in JavaScript
by benatkin 5y ago
That isn't a pattern, that's a preference. It's one that seemed appealing to me at one time but that I now disagree with because it's unidiomatic in JavaScript as well as Python and Ruby. I would hate to have this foisted upon me by a manager.
Side note: REST APIs should use custom headers so they can send back JSON arrays where appropriate. GitHub does this.
- fckthisguy 5y agoCould you expand on that side note? Seems interesting and I'm not familiar with the GH API.
- benatkin 5y agoHere's an example of an endpoint that returns a JSON array. Check the response body of the List Commits endpoint: https://docs.github.com/en/rest/reference/repos#list-commits https://docs.github.com/en/rest/reference/repos#list-commits You need a way to get to the next page. Some APIs might return it in the JSON response. GitHub returns it in the Link header (not really a custom header). Details here: https://docs.github.com/en/rest/guides/traversing-with-pagination https://docs.github.com/en/rest/guides/traversing-with-pagin...