var headers = new Headers(); headers.append('Content-Type', 'application/json'); headers.append('Authorization', 'Bearer ' + this.token); this.http.get('http://someurl/'+userId,{headers:headers}) .map(res => res.json()) .subscribe( data => { console.log(data); }, error => { console.log(error); if(error.status == 500) { this.dashResponse = false; this.notFoundResponse = false; this.serverErrorResponse = true; } else if(error.status == 404) { this.dashResponse = false; this.notFoundResponse = true; this.serverErrorResponse = false; } else if(error.status == 401) { this.router.navigate(['/login']); alert('Un Authorized'); this.refresh(); } else { this.dashResponse = false; this.notFoundResponse = false; this.serverErrorResponse = true; } } );
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)