I have an issue about google sheet api on vercel. I want to add a list to a sheet using with api. My function to add is async function appendRows(auth, sheetName, rows) {
try {
console.log(Appending to sheet: ${sheetName}
);
console.log(‘Rows to append:’, JSON.stringify(rows));
const response = await sheets.spreadsheets.values.get({
auth,
spreadsheetId: 'id',
range: `${sheetName}!A:A`,
});
const lastRow = response.data.values ? response.data.values.length : 0;
console.log("Last Row:", lastRow);
const range = `${sheetName}!A${lastRow + 1}`;
console.log('Updating range:', range);
const updateResponse = await sheets.spreadsheets.values.update({
auth,
spreadsheetId: 'id',
range: range,
valueInputOption: 'RAW',
resource: { values: rows },
});
console.log('Update response:', JSON.stringify(updateResponse.data));
console.log('Data successfully appended.');
} catch (error) {
console.error('Error appending data:', error);
console.error('Error details:', JSON.stringify(error, Object.getOwnPropertyNames(error)));
}
} It adds data to sheet in local, there is no problem with auth or function execution time on vercel. I saw some topic on stackoverflow but there is nothing to work. It is not working on both vercel dev and vercel prod.How I can solve this problem?