superagent-jsonp
superagent-jsonp copied to clipboard
Uncaught ReferenceError: callbackName is not defined
经常会出这个问题,偶现性
Could you please provide more information about this issue?
E.g. Browser / code example
Maybe are you sending multiple call at once with the same callbackName
?
superagent.get('exampleURL')
.use(superagentJSONP({ callbackParam: 'jsonp', callbackName: 'myCallbackName', timeout: 10000 }))
.end(function(err, res){
console.info(err, res)
});
superagent.get('exampleURL')
.use(superagentJSONP({ callbackParam: 'jsonp', callbackName: 'myCallbackName', timeout: 10000 }))
.end(function(err, res){
console.info(err, res)
});
superagent.get('exampleURL')
.use(superagentJSONP({ callbackParam: 'jsonp', callbackName: 'myCallbackName', timeout: 10000 }))
.end(function(err, res){
console.info(err, res)
});
The plugin cancel callbackName
window function after the request is ended.
If you use the same name on parallel calls only the first call will found the function stored in window
.
I had the same issue, specifying the timeout worked me. The callback is being removed from window
before it is called. Specifying the timeout option wasn't necessary in the prior version I was using. For a baseline, the response times range from 60ms to 150ms in my use case.
I had the same issue, providing .use(jsonp({timeout: 10000}))
solved the issue. Thanks.