diff --git a/lib/json-api-client/index.js b/lib/json-api-client/index.js index 42cc01b..62f1774 100644 --- a/lib/json-api-client/index.js +++ b/lib/json-api-client/index.js @@ -89,32 +89,29 @@ if ('linked' in response) { for (typeName in response.linked) { linkedResources = response.linked[typeName]; - for (j = 0, len1 = linkedResources.length; j < len1; j++) { - resourceData = linkedResources[j]; + linkedResources.forEach((resourceData) => { if (resourceData) { this.type(typeName).create(resourceData, headers, response.meta); } - } + }); } } results = []; if ('data' in response) { - for (k = 0, len2 = response.data.length; k < len2; k++) { - resourceData = response.data[k]; + response.data.forEach((resourceData) => { if (resourceData) { results.push(this.type(resourceData.type).create(resourceData, headers, response.meta)); } - } + }); } else { for (typeName in response) { resources = response[typeName]; if (indexOf.call(RESERVED_TOP_LEVEL_KEYS, typeName) < 0) { - for (l = 0, len3 = resources.length; l < len3; l++) { - resourceData = resources[l]; + resources.forEach((resourceData) => { if (resourceData) { results.push(this.type(typeName).create(resourceData, headers, response.meta)); } - } + }); } } }