小编Psi*_*Kai的帖子

NodeJS Invalid_grant gaxios.js:85:23

在我的 Node.js 应用程序中,我使用带有 oauth2 身份验证的 googleapis 来发送电子邮件。突然,我在启动应用程序时发现了这个错误。

(node:1333) UnhandledPromiseRejectionWarning: Error: invalid_grant
    at Gaxios._request (/Users/danielefarina/Desktop/GIT/server-worldmarker/src/node_modules/gaxios/build/src/gaxios.js:85:23)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async OAuth2Client.refreshTokenNoCache (/Users/danielefarina/Desktop/GIT/server-worldmarker/src/node_modules/google-auth-library/build/src/auth/oauth2client.js:170:21)
    at async OAuth2Client.refreshAccessTokenAsync (/Users/danielefarina/Desktop/GIT/server-worldmarker/src/node_modules/google-auth-library/build/src/auth/oauth2client.js:194:19)
    at async OAuth2Client.getAccessTokenAsync (/Users/danielefarina/Desktop/GIT/server-worldmarker/src/node_modules/google-auth-library/build/src/auth/oauth2client.js:214:23)
(node:1333) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1333) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled …
Run Code Online (Sandbox Code Playgroud)

node.js google-api-nodejs-client

3
推荐指数
1
解决办法
6274
查看次数

复杂解构:数组第一个索引内的对象位于另一个对象内

考虑这个“复杂”对象:

const obj = {
    nestedArray: [
        { stuff: "things" }
    ],
    nestedObj: {
        key1: "value1",
        key2: "value2"
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在寻找一种优雅的单行解决方案来解构key1key2stufffrom obj

我当前的解决方案如下所示并且工作得很好:

const { nestedArray, nestedObj: { key1, key2 } } = obj
const { stuff } = nestedArray[0]
Run Code Online (Sandbox Code Playgroud)

但我宁愿在一行中这样做:

const { array[0]: { stuff }, nestedObject: { key1, key2 } } = obj
Run Code Online (Sandbox Code Playgroud)

但显然这行不通。有什么方法可以像我想要的那样在一行中完成此操作吗?还是我对 ES6 要求太高了?我非常乐意接受“不”的答案,只要它提供了一个很好的解释为什么不。

javascript destructuring ecmascript-6

0
推荐指数
1
解决办法
440
查看次数