angular5.x 拦截器 switchMap

if (req.method === 'GET' && req.params.has('app_id')) {

return this.myAppListService.myListObservable.switchMap(() => {

let appId = this.myAppListService.selectedAppId;

newParams = req.params.set('app_id', appId);

const comReq = req.clone({

params: newParams,

body: newBody

});

return next.handle(comReq).do((res) => {

this.handleResponse(res);

});

});

}

if (req.method === 'POST' && req.headers.get('content-type').indexOf('application/x-www-form-urlencoded;') > -1) {

if (req.body.indexOf('app_id=')) {

return this.myAppListService.myListObservable.switchMap(() => {

let appId = this.myAppListService.selectedAppId;

newBody = req.body.replace(req.body.match(/(^|&)app_$)/)[0], '');

newBody = newBody + '&app_id=' + this.myAppListService.selectedAppId;

const comReq = req.clone({

params: newParams,

body: newBody

});

return next.handle(comReq).do((res) => {

this.handleResponse(res);

});

});

}

}