Open shen-sat opened 3 years ago
I think the array as a return to GET /<resource>s
is more conventional than an object mapping the IDs. One thing that might help is making the IDs more obviously not indices, e.g. using UUIDs.
Hi thanks for reporting this, I just want to make note that this repo is for the old archived version of the syllabus. You'll likely get a better response if you move this over to https://github.com/codeyourfuture/syllabus 🙂
I was involved in a lesson (as a teaching assistant) and came across the following scenario which confised the students (as well as me!)
In node week 2 we introduce a new variable
albumsData
which is an array of Beyonce albums.When we make the request
GET /albums/10
, we ideally want to return the album with an id of 10. However, some students (and teachers) interpreted this as returning the album with an index of 10 (becausealbumsData
is an array).In order to avoid this confusion (and to reflect real-world applications) we should change
albumsData
into a hash instead of an array, and return objects by their id instead of looping throughalbumsData
and returning albums of their index.