Is there a way to make the esri/request synchronous?
esriRequest(url, {
responseType: "json",
callbackParamName: "callback"
}).then(function(response){
console.log(resp);
});
Hi Flavie,
I had resolved this issue by making an API at my java code. And then call that API from my javascript making call synchronous.
Regards
Roshni
Hi Roshni,
I found another solution, I request myself with dojo class "request/xhr".
Regards,
Flavie
var layerInfo = null;
var requestURL = layerUrl + "?f=json";
requestXHR(requestURL, {
handleAs: "json",
sync: true,
headers: {
"X-Requested-With": null
}
}).then(function(data){
layerInfo = data;
});
return layerInfo;
Although I see you have the dojo class "request/xhr" property of sync set to a boolean value of true, then object still has a .then method promise.
Can you help me understand how this is synchronous please?
Hi Andres,
Check the doc for dojo/request/xhr here:
Thank you Leo.
I understand that the requestXHR function is set to sync.
But after it runs, it returns a promise, which would make it async again, right?
Hi Andres,
dojo/request/xhr uses XMLHttpRequest.open to perform the request. If 'sync' is true, the promise won't be returned until the request has completed.
Thank you Leo for your replies.
I will have to do a small test on different scenarios of this to see its' effect on the application's behavior.
Thanks worked like a charm.
Meghan Kulkarni