# NavigateToRoute() not always updating currentInstruction

**URL:** <https://discourse.aurelia.io/t/navigatetoroute-not-always-updating-currentinstruction/4026>\
**Category:** Help Requests\
**Created:** [February 8, 2021, 8:19pm UTC](https://discourse.aurelia.io/t/navigatetoroute-not-always-updating-currentinstruction/4026 "2021-02-08T20:19:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhysshadow](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/rhysshadow/32/1959_2.png) [@rhysshadow](https://discourse.aurelia.io/u/rhysshadow)\
**Post date:** [February 8, 2021, 8:19pm UTC](https://discourse.aurelia.io/t/navigatetoroute-not-always-updating-currentinstruction/4026/1 "2021-02-08T20:19:46Z")

</div>

I am trying to programatically navigate to a new route based on things happening in my javascript, but sometimes the page thinks it’s still on the current page and tries to load things that do not belong, resulting in javascript errors.

How can I update `currentInstruction` or make `navigateToRoute` function like I expect? Or am I missing some key component that would prevent this from happening?

Here’s my javascript code where I’m navigating to a new route:

search.js:

```auto
this.router.navigateToRoute('customer', params);

        console.log('current navigation', this.router.currentInstruction.config.name);
// when I log this, sometimes it shows 'customer' and sometimes 'search'

```

app.js

```auto
configureRouter( config, router )
  {
    config.title = 'ARIS';
    config.options.pushState = true;
    config.options.root = '/';

    config.map([
      {
        route: '', 
        name: 'home', 
        moduleId: PLATFORM.moduleName('home'), 
        nav: true, 
        title: 'Home',
      },
      {
        route: 'aris', 
        name: 'aris', 
        moduleId: PLATFORM.moduleName('aris'), 
        nav: false, 
        title: 'ARIS',
      },
      {
        route: 'login', 
        name: 'login', 
        moduleId: PLATFORM.moduleName('login'), 
        nav: false
      },
      {
        route: 'customer/:debtor_id?/:inv_num?', 
        name: 'customer', 
        moduleId: PLATFORM.moduleName('customer'), 
        nav: true, 
        href: 'customer',
        title: 'Customer',
        //activationStrategy: activationStrategy.invokeLifecycle,
      },
      {
        name: 'search',
        route: 'search', 
        moduleId: PLATFORM.moduleName('search'), 
        nav: true, 
        title: 'Search/Worklist',
        settings: {dropdown: true}
      },
      ]);

    config.mapUnknownRoutes('home');
    config.fallbackRoute('home');    
    this.router = router;
  }

```

I tried using `activationStrategy`, but this didn’t change what was going on, so I commented it out.

Any insight would be appreciated.

---

<div class="post-metadata">

**Author:** ![godfathr](https://avatars.discourse-cdn.com/v4/letter/g/9f8e36/32.png) [@godfathr](https://discourse.aurelia.io/u/godfathr)\
**Post date:** [September 29, 2021, 9:42pm UTC](https://discourse.aurelia.io/t/navigatetoroute-not-always-updating-currentinstruction/4026/2 "2021-09-29T21:42:01Z")

</div>

Were you able to figure out what you needed? I think I’m in the same situation and would be interested in what you did to get this to work (if you have a solution).

Thanks!

---

<div class="post-metadata">

**Author:** ![arnederuwe](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/arnederuwe/32/737_2.png) [@arnederuwe](https://discourse.aurelia.io/u/arnederuwe)\
**Post date:** [October 1, 2021, 1:56pm UTC](https://discourse.aurelia.io/t/navigatetoroute-not-always-updating-currentinstruction/4026/3 "2021-10-01T13:56:45Z")

</div>

`this.router.navigateToRoute('customer', params);` should take you to the provided route  
`console.log('current navigation', this.router.currentInstruction.config.name);` right after route navigation will probably be a race condition issue, as the router starts navigating and you don’t wait for navigation to finish.  
If you want to perform an action when route navigation completes, there are events for that, see here [Understanding Aurelia Router Events - I Like Kill Nerds](https://ilikekillnerds.com/2015/09/understanding-aurelia-router-events/)

I’m not sure I fully comprehend what you’re trying to do, could you elaborate on the functionality you’re trying to achieve?
