dingo-loader
A node.js module for deserializing resources from a dingo-based REST API, or any JSON API that carries a payload under data[<some-object-key>]
. For example, let's say you request.get
a feed that looks like this:
{ "status_code" : 200, "message" : "OK", "data" : { "products" : { "1" : { "id" : 1, "name" : "some product" }, "2" : { "id" : 2, "name" : "some other product" } } }}
and you want an array like this:
id: 1 name: 'some product' id: 2 name: 'some other product'
What you want is:
const dingoLoader = ; var arrayOfValues = ;
Constraints:
- If
status_code
is present, it must be in the 200's range. - If
message
is present, must be "OK". data
must be an object with only one key.