0

我试图在我的 index.js 中使用这些数据。我正在使用 promise 来扩展我的数据库用户的信息,如下所示:

Providers.Google({
  clientId: process.env.GOOGLE_ID,
  clientSecret: process.env.GOOGLE_SECRET,

  async profile(profile, tokens) {

    //setup query values
    let qv = profile;

    let userLookup = await query(
      prepare`SELECT * FROM users WHERE Nickname = 'Test' LIMIT 1`
    );

    if (!Object.keys(userLookup.data).length) {
      if (process.env.DEBUG >= 1) {
        console.log("[DEBUG] Sign In: User couldn't be found");
      }
      return Promise.reject(
        new Error(
          "We couldn't find your account, please check your email address and password and try again"
        )
      );
    }

    //de-nest the user data
    userLookup = userLookup.data[0];

    console.log(userLookup);

    return {
      id: profile.id,
      name: userLookup.Nickname,
      email: profile.email,
      image: profile.picture,
    };
  },

在我的索引中,我只是使用模板示例。

<div>
      {loading && <div>Loading...</div>}
      {session && (
        <>
          <p>Welcome, {session.user.name}</p>
          <br />
          <img src={session.user.image} alt="" />
        </>
      )}
      {!session && (
        <>
          <p>Please Sign in</p>
        </>
      )}
    </div>

我怎样才能name: userLookup.Nickname,从上面访问它,甚至像这样扩展它。

return {
      id: profile.id,
      anotherVariable: userLookup.anotherVariable
    };

谢谢。只是不知道它在哪里返回或如何访问它。

4

0 回答 0