# Cannot read properties of undefined (reading n )

**URL:** <https://community.auth0.com/t/cannot-read-properties-of-undefined-reading-n/126398>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [February 2, 2024, 4:48pm UTC](https://community.auth0.com/t/cannot-read-properties-of-undefined-reading-n/126398 "2024-02-02T16:48:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pulze](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pulze/32/54512_2.png) [@pulze](https://community.auth0.com/u/pulze)\
**Post date:** [February 2, 2024, 4:48pm UTC](https://community.auth0.com/t/cannot-read-properties-of-undefined-reading-n/126398/1 "2024-02-02T16:48:59Z")

</div>

Hello!

I’m having trouble where our users try to verify their email address, **it gets verified** , however the post verification link that redirects them to our website come with a query payload like this : [example.com/verify?supportSignUp=true&supportForgotPassword=true&email=user@email.adr&message=Cannot+read+properties+of+undefined+(reading+‘n’)&success=false&code=unknown](http://example.com/verify?supportSignUp=true&supportForgotPassword=true&email=user@email.adr&message=Cannot+read+properties+of+undefined+(reading+%27n%27)&success=false&code=unknown)

Anyone know why this could be?  
Or point me in the direction on how to debug this?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [February 2, 2024, 11:49pm UTC](https://community.auth0.com/t/cannot-read-properties-of-undefined-reading-n/126398/3 "2024-02-02T23:49:00Z")

</div>

Hi @pulze,

Welcome to the Auth0 Community!

It seems that the error is suggesting that there is bit of code that is trying to read `n` from a null object.

Could you check to see if you have any piece of code referencing `n`?

And could you see if redirecting your users to `{{ application.callback_domain }}` produces a different result?

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![pulze](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pulze/32/54512_2.png) [@pulze](https://community.auth0.com/u/pulze)\
**Post date:** [February 3, 2024, 11:09am UTC](https://community.auth0.com/t/cannot-read-properties-of-undefined-reading-n/126398/4 "2024-02-03T11:09:21Z")

</div>

I have found the issue, the template and/or our implementation of it was outdated.  
We have a MondgoDB database connected.  
The MongoDB verify actions script **template** goes the following:

```auto
function verify (email, callback) {
  const MongoClient = require('mongodb@3.1.4').MongoClient;
  const client = new MongoClient('mongodb://user:pass@localhost');

  client.connect(function (err) {
    if (err) return callback(err);

    const db = client.db('db-name');
    const users = db.collection('users');
    const query = { email: email, email_verified: false };

    users.update(query, { $set: { email_verified: true } }, function (err, result) {
      client.close();

      if (err) return callback(err);
      callback(null, result.result.n > 0);
    });
  });
}

```

There is the result.result.n is the one throwing the error, while the document update itself runs perfectly, and successfully.

The mongodb@3.1.4 signals that its too old, so i’ve used “mongodb” instead, to get the latest.

The fix was to update the code with the following :

```auto
users.updateOne(query, { $set: { email_verified: true } }, function (err, result) {
      client.close();

      if (err) return callback(err);
      callback(null, result.modifiedCount > 0);
    });

```

TLDR;  
update to updateOne, and result.result.n to result.modifiedCount.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [February 5, 2024, 8:18pm UTC](https://community.auth0.com/t/cannot-read-properties-of-undefined-reading-n/126398/5 "2024-02-05T20:18:50Z")

</div>

Hi @pulze,

Thanks for the update, and I’m glad that you have resolved the issue!

Feel free to reach out to us again if you have any additional questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 19, 2024, 8:19pm UTC](https://community.auth0.com/t/cannot-read-properties-of-undefined-reading-n/126398/6 "2024-02-19T20:19:49Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
