File tree Expand file tree Collapse file tree 1 file changed +8
-17
lines changed
Expand file tree Collapse file tree 1 file changed +8
-17
lines changed Original file line number Diff line number Diff line change @@ -117,27 +117,18 @@ function loadNewTree() {
117117 * @return {Promise<object> }
118118 * JSON object
119119 */
120- function loadOldTree ( ) {
121- const request = require ( 'request ') ;
120+ async function loadOldTree ( ) {
121+ log . message ( 'Loading old tree.json... ') ;
122122
123- return new Promise ( ( resolve , reject ) => {
124- log . message ( 'Loading old tree.json...' ) ;
125- request . get (
126- 'https://api.highcharts.com/highcharts/tree.json' ,
127- function ( error , response ) {
123+ const response = await fetch ( 'https://api.highcharts.com/highcharts/tree.json' ) ;
128124
129- if ( error ) {
130- reject ( error ) ;
131- return ;
132- }
133-
134- log . message ( 'Parsing old tree.json...' ) ;
125+ if ( ! response . ok ) {
126+ throw new Error ( `Failed to fetch old tree.json: ${ response . status } ${ response . statusText } ` ) ;
127+ }
135128
136- resolve ( JSON . parse ( response . body . toString ( ) ) ) ;
137- }
138- ) ;
129+ log . message ( 'Parsing old tree.json...' ) ;
139130
140- } ) ;
131+ return response . json ( ) ;
141132}
142133
143134/* *
You can’t perform that action at this time.
0 commit comments