Fetch Data From Google Sheet

let offset = 'A2';
let limit = 'Z999';
const sheetid = "<sheetid>"; 

const apikey = "<api key>"; 

const sheetname = "Sheet1";
const url = `https://sheets.googleapis.com/v4/spreadsheets/${sheetid}/values/${sheetname}!${offset}:${limit}?key=${apikey}`;

var sheet_data = [];

fetch(url).then(data => data.json()).then(data => { 
	sheet_data = data.values;
	console.table(sheet_data);
});
  • https://docs.google.com/spreadsheets/d/sheetid/edit?usp=sharing
  • create/get apikey from https://console.developers.google.com/apis/credentials

Leave a Reply

Your email address will not be published. Required fields are marked *