fix: add null check when accessing undefined keys

Co-authored-by: Hannes Kruse <hannes@octofox.de>
This commit is contained in:
alistair3149 2021-05-18 12:34:08 -04:00
parent 580f80bacc
commit 48deb87709
No known key found for this signature in database
GPG key ID: 94D081060FD3DD9C
2 changed files with 5 additions and 1 deletions

View file

@ -80,6 +80,10 @@ function convertDataToResults( data ) {
const results = []; const results = [];
if (typeof data?.query?.pages === 'undefined') {
return [];
}
/* eslint-disable-next-line compat/compat, es/no-object-values */ /* eslint-disable-next-line compat/compat, es/no-object-values */
data = Object.values( data.query.pages ); data = Object.values( data.query.pages );

View file

@ -22,7 +22,7 @@ function getUrl( input ) {
function convertDataToResults( data ) { function convertDataToResults( data ) {
const results = []; const results = [];
data = data.pages; data = data?.pages ?? [];
for ( let i = 0; i < data.length; i++ ) { for ( let i = 0; i < data.length; i++ ) {
results[ i ] = { results[ i ] = {