Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function request (url, params, callback, context) {
var paramString = encodeQueryString(params);
var requestLength = (url + '?' + paramString).length;
// to do: https://github.com/Esri/arcgis-rest-js/issues/114
// if (typeof context !== 'undefined' && context !== null) {
// if (typeof context.options !== 'undefined') {
// httpRequest.timeout = context.options.timeout;
// }
// }
if (requestLength <= 2000 && Support.cors) {
this.get(url, params, callback, context);
return;
} else if (requestLength > 2000 && Support.cors) {
this.post(url, params, callback, context);
return;
}
response = null;
}
if (!error && response.error) {
error = response;
response = null;
}
callback.call(context, error, response);
window._EsriLeafletCallbacks[callbackId] = true;
}
};
var script = DomUtil.create('script', null, document.body);
script.type = 'text/javascript';
script.src = url + '?' + encodeQueryString(params);
script.id = callbackId;
DomUtil.addClass(script, 'esri-leaflet-jsonp');
callbacks++;
return {
id: callbackId,
url: script.src,
abort: function () {
window._EsriLeafletCallbacks._callback[callbackId]({
code: 0,
message: 'Request aborted.'
});
}
};
}