AnsweredAssumed Answered

Esri Request and callbackParamName

Question asked by jsamek on Dec 13, 2017
Latest reply on Dec 19, 2017 by jsamek

I have a url that returns a callback (JSONP):



What is the proper way to use esriRequest with JSONP?


I have:

esriRequest(url, { callbackParamName: 'callback' }).then(function (result) {
}).otherwise(function (err) { console.log(err); });

This fails with an expected JSON error.


If I do:

esriRequest(url, { responseType:'jsonp', callbackParamName: 'callback' }).then(function (result) {
}).otherwise(function (err) { console.log(err); });

It returns the data ( as a string:

   "file": "Glens Falls/Glens Falls_302.15.pdf",
   "size": "372.72 kB"


If I do this inside, I can get the "file":

esriRequest(url, { responseType: 'jsonp', callbackParamName: 'callback' }).then(function (response) {

   var jsonp =;

   var f = new Function('callback', jsonp);
   f(function (json) {

}).otherwise(function (err) { console.log(err); });


Is this the right way to do this, or am I missing something? Any thoughts are appreciated.