I tried to do an auth. by using esriRequest.interceptors.push, but I couldn't get the response
here's my code:
require(["esri/Map",
"esri/views/MapView",
"esri/widgets/Search",
"esri/identity/IdentityManager",
"esri/identity/ServerInfo",
"esri/request",
"esri/config"], (Map, MapView, Search, IdentityManager, esriConfig, esriRequest) => {
if (esriRequest && esriRequest.interceptors) {
esriRequest.interceptors.push({
urls: "<on Premise ArcGIS url>", // Replace with your server URL pattern
before: function (params) {
console.log("Interceptor hit", params); // Log to check if the interceptor is working
params.requestOptions.headers = params.requestOptions.headers || {};
params.requestOptions.headers.Authorization = `Basic ${token}`;
},
error: function (error) {
console.error("Request error", error); // Log any errors in the request
return Promise.reject(error);
}
});
} else {
console.error("esriRequest or esriRequest.interceptors is not defined");
}
}
And always I get the "esriRequest or esriRequest.interceptors is not defined"
I use version 4.29 , anyone can solve this issue?