我正在尝试从Google电子表格获取值,该值将返回未定义的值。这是我的代码
app.get('\userdetails',(req,res) => {
Var doc = new GoogleSpredsheet('sheetId');
doc.useServiceAccountAuth(cred, function(err) {
doc.getRow(1, function (err, row){ console.log(row);});
});
});
我有我的证书 作为sheetId,我已经传递了具有编辑权限的工作表ID
答案 0 :(得分:1)
您需要检查,如果您在控制台日志中遇到这样的错误:
app.get('userdetails',(req,res) => {
Var doc = new GoogleSpredsheet('sheetId');
doc.useServiceAccountAuth(cred, function(err) {
if(!err){
doc.getRow(1,function(error,row){
if(!error && row){
console.log(row);
}else{
console.log('ERROR IN getRow :'+error);
}
});
}else{
console.log('ERROR IN useServiceAccountAuth : '+err);
}
});
});