Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 478 Bytes

README.md

File metadata and controls

15 lines (12 loc) · 478 Bytes

parse sheets json api data into something react can use.

This is the key:

fetch(API).then(response => response.json()).then(data => { let batchRowValues = data.valueRanges[0].values;

  const rows = [];
  for (let i = 1; i < batchRowValues.length; i++) {
    let rowObject = {};
    for (let j = 0; j < batchRowValues[i].length; j++) {
      rowObject[batchRowValues[0][j]] = batchRowValues[i][j];
    }
    rows.push(rowObject);
  }