I've been fumbling through trying to learn scripting for google sheets. The following returns the correct results. But, it stops my script and shows the following error. Any help would be much appreciated.
TypeError: Cannot read property 'pair' of undefined
var sh1=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("SCRIPT_DATA");
var requestOptions = {
'method': 'GET',
https://api.incscan.io/pdex/overview,
{
start: 1,
limit: 5000,
},
json: true,
gzip: true
};
var url='https://api.incscan.io/pdex/overview';
var result= UrlFetchApp.fetch(url, requestOptions);
var txt= result.getContentText();
var d=JSON.parse(txt);
for (var i=0; i<100;i++)
{
sh1.getRange(i+2, 7).setValue(d.perPair[i].pair);
sh1.getRange(i+2, 8).setValue(d.perPair[i].liquidity);
sh1.getRange(i+2, 9).setValue(d.perPair[i].volume);
}
sh1.getRange(2, 12).setValue(d.liquidity);
sh1.getRange(2, 13).setValue(d.allTimeVolume);