下面是我的代码。我使用节点 v12.16.3 和 npm v6.14.4。
const GoogleSpreadsheet = require('google-spreadsheet');
const {promisify} = require('util');
const creds = require('./client_secret.json');
控制台显示如下错误:
Uncaught (in promise) TypeError: promisify is not a function
我称之为承诺的地方:
async function accessSpreadsheet(){
const doc = new GoogleSpreadsheet(MY_GOOGLESHEET_ADDRESS);
await promisify(doc.useServiceAccountAuth)(creds);
const info = await promisify(doc.getInfo)();
const sheet = info.worksheets[0];
const rows = await promisify(sheet.getRows)({
offset:1
});
rows.forEach(row =>{
if(row.userid=='dog'){
var num = parseInt(row.point,10);
num+=1;
row.point = num;
row.save();
}
})
}
我应该怎么做才能解决错误?
nodejs的新手,我愿意知道和学习任何东西。谢谢!