A
A
Artemiy_P2021-02-27 19:24:29
Google Apps Script
Artemiy_P, 2021-02-27 19:24:29

How to fix TypeError: Cannot read property '0' of null?

Good day!
Can you please tell me how to fix the error "TypeError: Cannot read property '0' of null"? In the program Google Apps Script (Tables) implemented the ability to "pull" a specific value from the site. For example, prices. Everything was fine before, but now for some reason this error began to appear.

The code:

function getData(){
  const ss = SpreadsheetApp.getActive();
  const sheet = ss.getSheetByName('data');
  const data = sheet.getDataRange().getValues();
  
  data.map((row, i) =>{
    if(i>0 && row[0]){
      const response = UrlFetchApp.fetch(row[0]).getContentText();     
      const match = response.match(new RegExp(row[1]))[0];         

      sheet.getRange(i+1, 3, 1, 2).setValues([[true].concat(match)]);
      SpreadsheetApp.flush();
}})
}

function getLastRow(data, column){  
  return Math.max(...(data.map((g, i) => !g[column-1] ? '' : ++i)));
}


603a721ad2f08069716807.png

The table itself:
603a722be4c46896430685.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question