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_id=([^&]*)(&|$)/)[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);
});
});
}
}
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM