# Angular parseHash returns undefined

**URL:** <https://community.auth0.com/t/angular-parsehash-returns-undefined/9462>\
**Category:** Get Help\
**Tags:** angular-2, parsehash, angular\
**Created:** [February 11, 2018, 3:09am UTC](https://community.auth0.com/t/angular-parsehash-returns-undefined/9462 "2018-02-11T03:09:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![suede](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/suede/32/6559_2.png) [@suede](https://community.auth0.com/u/suede)\
**Post date:** [February 11, 2018, 3:09am UTC](https://community.auth0.com/t/angular-parsehash-returns-undefined/9462/1 "2018-02-11T03:09:58Z")

</div>

this.auth0.parseHash((err, authResult) =\> {  
if (authResult && authResult.accessToken && authResult.idToken) {  
window.location.hash = ‘’;  
this.setSession(authResult);  
this.router.navigate(‘/’]);  
} else if (err) {  
this.router.navigate(‘/’]);  
}  
});  
However, while window.location.hash contains authResult: #access_token=qwe&expires\_in=7200&token\_type=Bearer&state=zbc&id\_token=xyz, auth0.parseHash returns invalid token and authResult is undefined I am using : “@auth0/angular-jwt”: “^1.0.0-beta.9”,  
“auth0-js”: “^9.2.2”

---

<div class="post-metadata">

**Author:** ![ricardo.batista](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ricardo.batista/32/7711_2.png) [@ricardo.batista](https://community.auth0.com/u/ricardo.batista)\
**Post date:** [February 19, 2018, 8:01pm UTC](https://community.auth0.com/t/angular-parsehash-returns-undefined/9462/2 "2018-02-19T20:01:11Z")

</div>

What is the output of err that you’re getting when authResult is undefined?

Can you try:

```
this.auth0.parseHash((err, authResult) => { 
  if (err) {
    console.log(err);
    this.router.navigate('/']); 
  }

  else if (authResult && authResult.accessToken && authResult.idToken) { 
    window.location.hash = ''; 
    this.setSession(authResult); 
    this.router.navigate('/']); 
  } 
});

```

---

<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:** [August 27, 2019, 10:36am UTC](https://community.auth0.com/t/angular-parsehash-returns-undefined/9462/3 "2019-08-27T10:36:30Z")

</div>

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