angular2-resolve

Angular2 router with Http data service through a Resolve with Observable catching 404

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 12:14:46
问题 In my resolve guard I am getting an Http Observable to return the JSON of a user from a particular id . I want to catch an error and reroute to the users overview if the id does not exist. I have seen code that solves that with a Promise, but not with an Observable. I would like to see a solution with an Observable! Currently I get an "EXCEPTION: Uncaught (in promise): Response with status: 404 Not Found for URL: http://127.0.0.1:3000/users/191" since user 191 does not exsist. Here is my code

Angular2 router with Http data service through a Resolve with Observable catching 404

倾然丶 夕夏残阳落幕 提交于 2019-12-06 05:04:34
In my resolve guard I am getting an Http Observable to return the JSON of a user from a particular id . I want to catch an error and reroute to the users overview if the id does not exist. I have seen code that solves that with a Promise, but not with an Observable. I would like to see a solution with an Observable! Currently I get an "EXCEPTION: Uncaught (in promise): Response with status: 404 Not Found for URL: http://127.0.0.1:3000/users/191" since user 191 does not exsist. Here is my code: Resolve: import { Injectable } from '@angular/core'; import { Resolve, ActivatedRouteSnapshot,