# Aurelia 2 router configuration bug

**URL:** <https://discourse.aurelia.io/t/aurelia-2-router-configuration-bug/5342>\
**Category:** Help Requests\
**Created:** [January 18, 2024, 1:35pm UTC](https://discourse.aurelia.io/t/aurelia-2-router-configuration-bug/5342 "2024-01-18T13:35:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![StefanNj](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/stefannj/32/1671_2.png) [@StefanNj](https://discourse.aurelia.io/u/StefanNj)\
**Post date:** [January 18, 2024, 1:35pm UTC](https://discourse.aurelia.io/t/aurelia-2-router-configuration-bug/5342/1 "2024-01-18T13:35:04Z")

</div>

[This](https://docs.aurelia.io/getting-to-know-aurelia/routing/aurelia-router/creating-routes#passing-information-between-routes) is an example from documentation  
I added data to route configuration:  
`data: { data1: "data1" }`  
and when I’m trying access this data, I get data: undefined.

---

<div class="post-metadata">

**Author:** ![bigopon](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/bigopon/32/18_2.png) [@bigopon](https://discourse.aurelia.io/u/bigopon)\
**Post date:** [March 15, 2024, 5:36am UTC](https://discourse.aurelia.io/t/aurelia-2-router-configuration-bug/5342/2 "2024-03-15T05:36:46Z")

</div>

> and when I’m trying access this data, I get data: undefined.

Where are you trying to access this `data`?

---

<div class="post-metadata">

**Author:** ![zhanglongyu](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/zhanglongyu/32/2500_2.png) [@zhanglongyu](https://discourse.aurelia.io/u/zhanglongyu)\
**Post date:** [March 15, 2024, 2:41pm UTC](https://discourse.aurelia.io/t/aurelia-2-router-configuration-bug/5342/3 "2024-03-15T14:41:04Z")

</div>

I have same problem. I am trying to access it in global lifecyclehook ‘canLoad’ function.

---

<div class="post-metadata">

**Author:** ![bigopon](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/bigopon/32/18_2.png) [@bigopon](https://discourse.aurelia.io/u/bigopon)\
**Post date:** [March 15, 2024, 11:09pm UTC](https://discourse.aurelia.io/t/aurelia-2-router-configuration-bug/5342/4 "2024-03-15T23:09:05Z")

</div>

is the lifecycle on the view model, or on a lifecycle hook?  
If it’s on the view model, then it’s a bug, but this is a very basic usage, I think it’s unlikely to be a bug.  
If it’s on a lifecycle hook, then params is the 2nd argument, the 1st argument is the view model instance the hook is invoked on.  
Maybe paste some code here so we can see why easier?

---

<div class="post-metadata">

**Author:** ![zhanglongyu](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/zhanglongyu/32/2500_2.png) [@zhanglongyu](https://discourse.aurelia.io/u/zhanglongyu)\
**Post date:** [March 16, 2024, 4:12am UTC](https://discourse.aurelia.io/t/aurelia-2-router-configuration-bug/5342/5 "2024-03-16T04:12:00Z")

</div>

It’s on a lifecycle hook, here is my code. (from docs)

```auto
@lifecycleHooks()
class AuthHandler {
  canLoad(viewModel, params: Parameters, instruction: RoutingInstruction, navigation: Navigation) { 

    console.log("params",params);
    console.log("navigation",navigation);
    return true; 
  }
}

```

The output of params is ‘{}’ ,  
The output of navigation is an object , but it’s ‘data’ property is undefined. I think I should use this, not params, right?

This is my route configuration

```auto
    static routes: IRoute[] = [
        {
            path: ['login-page'],
            component: LoginPage,
            title: 'Login',
        },
        {
            path: ['main'],
            component: ContentPage,
            title: 'Content 2',
            data: { auth: true }
        }
    ]

```

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![ivan](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/ivan/32/2022_2.png) [@ivan](https://discourse.aurelia.io/u/ivan)\
**Post date:** [March 18, 2024, 8:48am UTC](https://discourse.aurelia.io/t/aurelia-2-router-configuration-bug/5342/6 "2024-03-18T08:48:23Z")

</div>

Try renaming `data` to `parameters`

```auto
{
            path: ['main'],
            component: ContentPage,
            title: 'Content 2',
            parameters: { auth: true }
}

```

I think the current documentation is mixing `router-lite` and `router` logic.

---

<div class="post-metadata">

**Author:** ![StefanNj](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/stefannj/32/1671_2.png) [@StefanNj](https://discourse.aurelia.io/u/StefanNj)\
**Post date:** [March 18, 2024, 9:18am UTC](https://discourse.aurelia.io/t/aurelia-2-router-configuration-bug/5342/7 "2024-03-18T09:18:44Z")

</div>

Thanks, it works with parameters!

---

<div class="post-metadata">

**Author:** ![zhanglongyu](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/zhanglongyu/32/2500_2.png) [@zhanglongyu](https://discourse.aurelia.io/u/zhanglongyu)\
**Post date:** [March 18, 2024, 3:37pm UTC](https://discourse.aurelia.io/t/aurelia-2-router-configuration-bug/5342/8 "2024-03-18T15:37:51Z")

</div>

I switched to router-lite now, because I think it’s documentation is more accurate and api is cleaner. Thanks any way!
