I'm trying to use the esriConfig.request.interceptors to attach a token for a secured service which works until I try to fetch the legend info for the same url base.
esriConfig.request.interceptors.push({
urls: "https://gis.wgfd.wyo.gov/arcgis/rest/services/OneSteppe/OneSteppe_ExistingDisturbance_WyGISC/",
before: function (params) {
params.requestOptions.query = params.requestOptions.query || {};
params.requestOptions.query.token = "theToken";
},
});
The fetch I'm using:
fetch('https://gis.wgfd.wyo.gov/arcgis/rest/services/OneSteppe/OneSteppe_ExistingDisturbance_WyGISC/MapServ... (response) { return response.json() }).then(function (legend) {console.log(legend)})
error is 499 "Token Required".
Thanks in advance for any help.
Jason.
Solved! Go to Solution.
The interceptors only work when using the request method of the JSAPI.
https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html
It uses fetch under the hood, but can't intercept native fetch requests.
The interceptors only work when using the request method of the JSAPI.
https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html
It uses fetch under the hood, but can't intercept native fetch requests.
Thank you. So in this case I would pass the token in the query string of the request, I take it?