2
- 要求が失敗した場合、成功の再失敗した要求
- を送信する場合、何かの非同期(バックグラウンドで再ログイン)
- を行う
- 、エラーをキャッチ
が失敗するとエラーがスローされます。
class MyHttpWrapper { ctor(private http:Http) {} get (url, options) { //Do some pre request things with the options and url return this.get(url,options) .map(res => res.json()) .catch((err, source) => { // Here i want to reloging someService.login().subscribe(res => //Here i want to re-execute the original request and return it to the caller of the myHttpwrapper.get() caller ).catch(err => //return error to the caller of the myHttpWrapper.get() ) } }
はどのように私はそれを行うことができますか?
'map'演算子の使用を外部化することによってコードサイズを少し減らします... –
' flatMap'の後の '.catch'はログイン時にエラーを捕捉するのでしょうか? – tubu13
はい、それは 'flatMap'によって返された観測値に適用されるので、そのようなエラーをキャッチします。 –