API SpreadSheets Google - PullRequest
       11

API SpreadSheets Google

0 голосов
/ 15 ноября 2018

при выполнении кода из документации https://developers.google.com/sheets/quickstart/nodejs?fbclid=IwAR0KmCnMNwsPkzuB93pB8YKaWot7IkAtxWqgLANR1Z08kuRKSl-r3DbqMrY#step_3_set_up_the_sample, после ввода ключа URL (аккаунт гугл для аутентификации)

появляется эта ошибка:

node: 5868) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_CALLBACK]: C
llback must be a function
in maybeCallback (fs.js: 129: 9)
in Object.writeFile (fs.js: 1156: 14)
in storeToken (C: \ Users \ ELIOT \ Desktop \ demoDialoglow \ api.js: 100: 6)
in C: \ Users \ ELIOT \ Desktop \ demoDialoglow \ api.js: 79: 7
in getTokenAsync.then.r (C: \ Users \ ELIOT \ Desktop \ demoDialoglow \ node_modules \ go
gle-auth-library \ build \ src \ auth \ oauth2client.js: 97: 51)
in process._tickCallback (internal / process / next_tick.js: 68: 7)
node: 5868) UnhandledPromiseRejectionWarning: Rejection of uncontrolled promise. This e
Ror originated either by throwing inside an asynchronous function without a capture bl
ck, or rejecting a promise that was not handled with .catch (). (Rejection ID
one)
node: 5868) [DEP0018] DeprecationWarning: unmanaged promise rejects are obsolete
In the future, rejections of promise that are not handled will end the N
Process .js with a non-zero exit code.

1 Ответ

0 голосов
/ 15 ноября 2018

Это связано с обновлением модуля NodeJS fs. Просто добавьте пустую функцию в качестве третьего параметра:

fs.writeFile(TOKEN_PATH, JSON.stringify(token), function(){});

или с синтаксисом ES6:

fs.writeFile(TOKEN_PATH, JSON.stringify(token), () => {});

Обратитесь к этому сообщению для более подробной информации: Почему узел 10 сделал обязательным передавать обратный вызов в fs.writeFile ()?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...