i'm trying use flatmap make bunch of parallel requests. problem though if 404, whole chain breaks , remainder of requests cancelled. there way catch 404 , return empty response? getiterationsdashboard initial method run.
getallprojects(): observable<models.project[]> { var = this; var authheader = new headers(); authheader.append('authorization', `basic ${new buffer('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:').tostring('base64')}`); authheader.append('x-tfs-fedauthredirect', 'suppress'); return this.http.get(`${this.baseurl}`, { headers: authheader }).map(res => { let body: models.getprojectsresponse = res.json(); return body.value; }); } getallteams(project: models.project): observable<models.team[]> { var = this; var urls = []; return this.makegetrequest<models.getteamsresponse>(`https://technossus.visualstudio.com/defaultcollection/_apis/projects/${project.id}/teams`).map(response => { return response.value; }).catch(err => { return observable.empty<models.team[]>(); }); } getallcurrentiterations(teamid: string, projectid: string): observable<models.iteration[]> { return this.makegetrequest<models.getiterationsresponse>(`https://technossus.visualstudio.com/defaultcollection/${projectid}/${teamid}/_apis/work/teamsettings/iterations?$timeframe=current`).map(response => { return response.value; }).catch((ex, caught) => { console.log('couldn\'t team'); return observable.from<models.iteration[]>({ length: 0, value:[] }); }); } getiterationsdashboard() { var = this; return this.getallprojects().flatmap(projects => { let dashboard: models.teamsprintdashboard[] = []; return observable.forkjoin(projects.map(project => { return that.getallteams(project).flatmap(teamsresponse => { return observable.forkjoin(teamsresponse.map(team => { return that.getallcurrentiterations(team.id, project.id).map(iterations => { return { projectid: project.id, teamid: team.id, iterations: iterations ? iterations : [] }; }).catch(ex => { console.log('no success'); return observable.empty(); }); })).catch(err => { return observable.empty(); }); }); })); }); } makegetrequest<t>(requesturl): observable<t> { var authheader = new headers(); authheader.append('authorization', `basic ${new buffer('k3ulyrj5xaid5tpr7l2hlhgtxeqynmvmlcwa4v47kn6l25eupqkq:').tostring('base64')}`); authheader.append('x-tfs-fedauthredirect', 'suppress'); return this.http.get(requesturl, { headers: authheader }).map(res => { let body: t = res.json(); return body; }).catch(err => { return observable.empty<t>(); }); }
i think catch
should want (needs imported):
return this.http.get(`${this.baseurl}`, { headers: authheader }).map(res => { let body: models.getprojectsresponse = res.json(); return body.value; }).catch(err => observable.of(null));