尝试编写将用户信息附加到电子表格的Firebase云功能。我希望更新范围的值,以便用户改变主意来更新电子表格时可以使用它。
async function writeToSpreadSheet(firstName: string, lastName: string, response: string, spreadSheetId: string, date:string, userEmail:string): Promise<Schema$AppendValuesResponse> {
await sheets.spreadsheets.values.append({
auth: jwtClient,
spreadsheetId: spreadSheetId,
range: 'Sheet1!A1:C3', // update this range of cells
valueInputOption: 'RAW',
requestBody: {"values": [[firstName, lastName,userEmail, response, date]]},
}, (err, res) => {
if(err){
console.log(err);
return;
}
console.log(res);
return;
});
}
由于某种原因,我得到了巨大的反响,如:
{ status: 200,
statusText: 'OK',
headers:
{ 'content-type': 'application/json; charset=UTF-8',
vary: 'Origin, X-Origin, Referer',
...
}
而不是一个不错的:
{
"spreadsheetId": "{spreadsheetId}",
"tableRange": "Sheet1!A1:C18",
}
答案 0 :(得分:0)
spreadsheetId
和tableRange
的属性作为响应。如果我的理解是正确的,那么该修改如何?
await sheets.spreadsheets.values.append({
auth: jwtClient,
spreadsheetId: spreadSheetId,
range: 'Sheet1!A1:C3', // update this range of cells
valueInputOption: 'RAW',
requestBody: {"values": [[firstName, lastName,userEmail, response, date]]},
fields: "spreadsheetId,tableRange", // Added
}, (err, res) => {
if(err){
console.log(err);
return;
}
console.log(res.data); // Modified
return;
});
如果我误解了你的问题,我表示歉意。