I am unable to update the sheets row value of a particular cells. I am using google api v4.0 and google spreadsheet npm package. I am getting an error using it in discord bot js. The error is
(node:5956) UnhandledPromiseRejectionWarning: TypeError: rows2[i].save is not a function at checkStatus (D:\discortbot\src\bot.js:95:30)
My code is as follows:
sheet3 = doc2.sheetsByIndex[sheetIndex]; // Data from back which I have checked is coming correctly!
var rows2 = await sheet3.getRows({
});
rows2 = rows2.map(a=>a._rawData);
var size = rows2.length;
for(var i=0;i<size;i++){
if(rows2[i][0]==email){
rows2[i].candidateID = userID;
rows2[i].RoleID = sheetarr[2];
//rows2[i].save(); This one is also not working
console.log(rows2[i].candidateID); // Values are printing in console
console.log(rows2[i].RoleID); // Values are printing in console
await rows2[i].save(); // Error giving me
verified = 1;
break;
}
}
if(verified==1){
message.author.send("Your account has been verified.Welcome to Outscal batch!");
}else{
}
I am not able to understand why I am getting this error? Kindly help me in solving this.
How about the following modification?
Before you use this script, please confirm the variables you want to use, again.
var sheet3 = doc2.sheetsByIndex[sheetIndex];
var rows2 = await sheet3.getRows();
// rows2 = rows2.map(a=>a._rawData); // Removed
var size = rows2.length;
for (var i = 0; i < size; i++) {
if (rows2[i]._rawData[0] == email) { // Modified
rows2[i].candidateID = userID;
rows2[i].RoleID = sheetarr[2];
console.log(rows2[i].candidateID); // Values are printing in console
console.log(rows2[i].RoleID); // Values are printing in console
await rows2[i].save();
verified = 1;
break;
}
}
if (verified == 1) {
message.author.send("Your account has been verified.Welcome to Outscal batch!");
} else {
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.