PokeAPI / pokeapi-js-wrapper

PokeAPI browser wrapper, fully async with built-in cache
Mozilla Public License 2.0
273 stars 43 forks source link

fix Array check statement #24

Closed ngjamesng closed 3 years ago

ngjamesng commented 3 years ago

In the current version, if you pass any type of an object/non-primitive data, like a JavaScript object: } else if (typeof {key1: 1, key2:2 } === 'object') { this else-if-statement would trigger, and would try to pass in the object into return Promise.all(), which can only take in an array.

This Pull request changes the check if an item is an object, to something more specific to what the Promise.all() method can accept, which is an array. The suggested change is from:

 } else if (typeof path === 'object') {

to:

 } else if (Array.isArray(path)) {
Naramsim commented 3 years ago

Thanks for the contribution!