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/MapServer/legend?f=json').then(function (response) { return response.json() }).then(function (legend) {console.log(legend)})
error is 499 "Token Required".
Thanks in advance for any help.
Jason.
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?
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.