getAllJSON()
is very useful to retrieve a bunch of paginated JSON objects, but it has an annoying requirement: we always need to define two generic Type parameters, the first one for the type of item we expect to get as an array TypeOfArrayItem
, and the second one TypeOfJSONPayload
for the shape of the JSON payload we expect to get from the endpoint. Most of the time, TypeOfJSONPayload
is really ReadonlyArray<TypeOfArrayItem>
. Thus, we should provide this as a default value for this type parameter. It would save developers the trouble of figuring out which parameter goes where: they want an array of TypeOfArrayItem
, they just give this and are done. When they are dealing with a special REST endpoint that returns an object, they can provide the second generic type parameter at the same time as the getCollectionCallback
option.