我有一个可以包含多个HTTP请求的Angular2 ForkJoin。当ForkJoin出错时,我希望能够确定ForkJoin中导致错误的请求URL的子域/域。如果错误是401 Unauthorized,那么我需要尝试重新建立新连接。我需要失败请求的子域/域,以便我可以查找凭据以重新建立令牌,然后再次尝试ForkJoin请求。我的ForkJoin可能会向不同的域发出多个请求。
return Observable.create(observer =>
{
//JOIN ALL REQUESTS TOGETHER INTO A BATCH TO BE FORKED....
let observableBatch = [];
//ADD OBSERVABLE FOR SINGLE GET REQUEST
if (requestModel.Get)
{
observableBatch.push(this.HttpGet(requestModel.Get));
}
//ADD OBSERVABLE FOR AN ARRAY OF GET REQUESTS
if (requestModel.GetList)
{
for (let item in requestModel.GetList)
{
observableBatch.push(this.HttpGet(requestModel.GetList[ item ]));
}
}
//ADD OBSERVABLE FOR SINGLE POST REQUEST
if (requestModel.Post)
{
observableBatch.push(this.HttpPost(requestModel.Post));
}
//ADD OBSERVABLE FOR AN ARRAY OF POST REQUESTS
if (requestModel.PostList)
{
for (let item in requestModel.PostList)
{
observableBatch.push(this.HttpPost(requestModel.PostList[ item ]));
}
}
/*
FORK JOIN RETURNS AN ARRAY OF RESULT SETS (1 FOR EACH REQUEST IN FORK JOIN)
THIS OBSERVABLE, IF SUCCESSFUL, RETURNS THE FOLLOWING:
[1..N] - THE RAW JSON FROM CMS SERVICE
*/
let forkJoinSubscription = Observable.forkJoin(observableBatch)
.subscribe (
//SUCCESS, WE HAVE JSON RESPONSE(S)
data =>
{
console.log('FORK JOIN SUCCESS !!!', data);
},
//ERROR
err =>
{
console.log('FORK JOIN ERROR...', err);
},
//COMPLETE
() =>
{
if (forkJoinSubscription)
{
forkJoinSubscription.unsubscribe();
}
//console.log('FORK JOIN COMPELETED');
}
);
});

发生错误时,是否可以在ForkJoin中的一批URL中确定URL的子域/域?