I am using a chrome extension to update sheets through Apps Script.
There are 14 rows to update and I am sending the data for each row one by one. But the problem is that if I run the program once, it would update, let's say, 5 rows. If I run the program again, it will update some other number of rows. And another interesting thing is, every time I run the program, it will send different rows. The rows are never same.
Code.gs
function doGet(e){
var sheetID=e.parameter.sheetID;
var firstName = e.parameter.firstName;
var lastName = e.parameter.lastName;
var count = e.parameter.count
var ss = SpreadsheetApp.openById(spreadsheetId);
SpreadsheetApp.setActiveSpreadsheet(ss);
ss.appendRow([
firstName,
lastName,
count
]);
}
Here count
is the variable I send to check which rows are getting saved to sheets. And for every execution, this value differs. Sometimes it's [0, 12, 1, 3, 5] (when only 5 out of 14 rows gets saved) and other times it's [1, 5, 14, 13] (when only 4 out of 14 rows gets saved)
This is of course without making any changes in the code.
Following is the GET
request that is sent from backgroun.js
background.js
params = 'firstName=' + firstName + '&' + 'lastName=' + lastName + '&' + 'count=' + count
url = url + encodeURI(params)
console.log(url)
fetch(url, {
method: 'GET',
mode: 'no-cors',
})
.then((response) => response)
.then((data) => {
console.log(data);
})
.catch((error) => {
console.error('Error:', error);
});
What am I possibly doing wrong? Am I missing something?