Reputation: 1
Below is my code. I use node v12.16.3 and npm v6.14.4.
const GoogleSpreadsheet = require('google-spreadsheet');
const {promisify} = require('util');
const creds = require('./client_secret.json');
And the console showed error like this:
Uncaught (in promise) TypeError: promisify is not a function
Where I call promisify:
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();
}
})
}
What should I do to solve the error?
New for nodejs ,I will be willing to know and learn anything.Thanks!
Upvotes: -1
Views: 749
Reputation: 197
You should use promisify variable without { }
const promisify = require('util');
or
const util = require('util');
util.promisify(some code);
Upvotes: -1