Hi,
Arcgis 4.x JSAPI
esriConfig.request.interceptors support multiple interceptors?
It takes an array of interceptors, each can intercept a different URL, so yes, it can.
https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request
Hi,
This is also what I thought but unfortunately it does not work..
Here is an pen example.
https://codepen.io/Dvirus/pen/GRMdzLW?editors=1001
You need to specify the "urls" string so the interceptor knows which URL should be intercepted. the way you have it set up the "urls" is null or undefined, so the first one overwrites the second.
Thanks you! it's working!
Apparently Arcgis Experience Builder already add interceptor at file
client\dist\jimu-arcgis\index.js (it's built minified)
(e=re.request.interceptors)||void 0===e||e.push({after:e=>{var t,i;(null===(t=null==e?void 0:e.url)||void 0===t?void 0:t.indexOf("/rest/info"))&&(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.owningSystemUrl)&&this.registOAuthInfo(e.data.owningSystemUrl)}}),
but they add interceptor without urls property
so even if I add urls
esriConfig.request.interceptors.push({
urls: /FeatureServer\/\d+/,
after: function (response) {
response.data.supportedQueryFormats = "JSON";
}
});
It's not intercept.
I tried to add urls to the first interceptor
esriConfig.request.interceptors[0].urls = /.*?/
or
esriConfig.request.interceptors[0].urls = /.*/
esriConfig.request.interceptors[0].urls = /blalba.*/
esriConfig.request.interceptors.push({
urls: /FeatureServer\/\d+/,
after: function (response) {
debugger;
response.data.supportedQueryFormats = "JSON";
}
});
esriConfig.request.interceptors.reverse();