File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -118,14 +118,7 @@ function loadImageAsync(url) {
118118``` javascript
119119const getJSON = function (url ) {
120120 const promise = new Promise (function (resolve , reject ){
121- const client = new XMLHttpRequest ();
122- client .open (" GET" , url);
123- client .onreadystatechange = handler;
124- client .responseType = " json" ;
125- client .setRequestHeader (" Accept" , " application/json" );
126- client .send ();
127-
128- function handler () {
121+ const handler = function () {
129122 if (this .readyState !== 4 ) {
130123 return ;
131124 }
@@ -135,6 +128,13 @@ const getJSON = function(url) {
135128 reject (new Error (this .statusText ));
136129 }
137130 };
131+ const client = new XMLHttpRequest ();
132+ client .open (" GET" , url);
133+ client .onreadystatechange = handler;
134+ client .responseType = " json" ;
135+ client .setRequestHeader (" Accept" , " application/json" );
136+ client .send ();
137+
138138 });
139139
140140 return promise;
You can’t perform that action at this time.
0 commit comments