I'm trying to update a given spreadsheet cell, using node.js googleapis v4 and authorizing with a JWT client.
Reading works fine, but I cannot understand how to write:
new Promise((resolve, reject) => {
sheets.spreadsheets.values.update({
auth: this._auth,
spreadsheetId: this._metaData.spreadSheetId,
range: range,
valueInputOption: 'USER_ENTERED'
},(err, resp) => {
if (err) {
console.log('Data Error :', err)
reject(err);
}
resolve(resp);
});
});
How do I specify the data, and how do I pass it to the call?
I understand I should use a ValueRange object, but how?
After better reviewing the (poor) documentation, I inferred that you had to pass a request object in the call:
return new Promise((resolve, reject) => {
sheets.spreadsheets.values.update(
{
auth: this._auth,
spreadsheetId: this._metaData.spreadSheetId,
range: "Sheet1!A1",
valueInputOption: "USER_ENTERED",
resource: { range: "Sheet1!A1", majorDimension: "ROWS", values: [["b"]] },
},
(err, resp) => {
if (err) {
console.log("Data Error :", err);
reject(err);
}
resolve(resp);
}
);
});