Skip to content

Commit

Permalink
Merge pull request #34 from michaelvial/handle_onerror
Browse files Browse the repository at this point in the history
Handle <script> error event
  • Loading branch information
camsong authored Jun 7, 2017
2 parents 541c6c9 + 36ff089 commit f121ddc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/fetch-jsonp.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ function fetchJsonp(_url, options = {}) {
jsonpScript.setAttribute('charset', options.charset);
}
jsonpScript.id = scriptId;
jsonpScript.onerror = () => {
reject(new Error(`JSONP request to ${_url} failed`));

clearFunction(callbackFunction);
removeScript(scriptId);
}
document.getElementsByTagName('head')[0].appendChild(jsonpScript);

timeoutId = setTimeout(() => {
Expand Down

0 comments on commit f121ddc

Please sign in to comment.