How to handle net::ERR_CONNECTION_REFUSED in Angular2

后端 未结 3 522
臣服心动
臣服心动 2021-02-07 01:30

error-handling shows how to handle errors as follows:

private handleError (error: Response | any) {
  // In a real world app, we might use a remote logging infra         


        
3条回答
  •  悲哀的现实
    2021-02-07 02:10

    //First inject the router in the constructor
    
    
    private handleError (error: Response | any) {
    //Your other codes    
    
    if (error.status == 0){ //or whatever condition you like to put
    this.router.navigate(['/error']);
    }
    }
    

提交回复
热议问题