Skip to content

Commit

Permalink
fix: search for data/meta/error keys
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Sep 6, 2019
1 parent 9d4836a commit 847163a
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ const searchDataByKey = (searchKey, object) => {
return null;
}

if (object[searchKey]) {
return object[searchKey];
}

for (let key in object) {
if (key === searchKey) {
return object.data;
const value = searchDataByKey(searchKey, object[key]);
if (value) {
return value;
}

return searchDataByKey(searchKey, object[key]);
}

return null;
Expand Down

0 comments on commit 847163a

Please sign in to comment.