Angular router: promise returned from navigatebyurl is ignored

Sammy

Using this code:

this.router.navigateByUrl('/login');

I get the following warning: promise returned from navigatebyurl is ignored. How and when would I want to handle the promise here?

P.S. I'm using this in AuthGuard's canActivate.

Amir BenAmara

The navigateByUrl function returns a promise so you can use .then() method :

this.router.navigateByUrl('/login').then(() => {
    // Do something 
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Promise not returned from recursive function

Intellij Idea warning - "Promise returned is ignored" with aysnc/await

How to use router.navigateByUrl and router.navigate in Angular

Objects returned from promise are undefined

NodeJS Bluebird promise created in a handler but was not returned from it

How to get data returned from fetch() promise?

Push the value returned from a promise into an array

Nothing was returned from render at promise return

Creating a test from Angular query parameter returned as a promise

Why is string returned from promise undefined?

Fetch Error "Promise returned from fetchData is ignored"

Angular 9 - how to test a service that calls navigateByUrl by mocking the router

Filtering an array returned from Promise

Why a promise with a value undefined is returned from "findLocation()"?

Nothing returned When doing $http Promise in Angular

Setting Member Variable from within returned promise

How to check if data returned from a promise is empty

"A promise was created in a handler but was not returned from it"

Simple example for "a promise was created in a handler but was not returned from it"

Why is no value returned from my Promise?

Assigning data returned from promise to a variable object

Ionic 4 Router does not have navigate and navigateByUrl

How to get parameter from navigateByUrl?

Result from database with promise is not returned properly in nodeJS

How to mock router.navigateByUrl(...).then in Angular with Karma and Jasmine

Get value returned from Promise in JavaScript

Using array map on returned value from promise

Angular 15 this.router.navigate is not a function, this.router.navigateByUrl is NOT a function

Router is ignored