File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,11 +93,20 @@ window.document.addEventListener('drop', async e => {
9393 fileInput . files = files ;
9494 fileInput . dispatchEvent ( new Event ( 'change' ) ) ;
9595 } else if ( url ) {
96- const request = await fetch ( url ) ;
97- const data = new DataTransfer ( ) ;
98- data . items . add ( new File ( [ await request . blob ( ) ] , 'image.png' ) ) ;
99- fileInput . files = data . files ;
100- fileInput . dispatchEvent ( new Event ( 'change' ) ) ;
96+ try {
97+ const request = await fetch ( url ) ;
98+ if ( ! request . ok ) {
99+ console . error ( 'Error fetching URL:' , url , request . status ) ;
100+ return ;
101+ }
102+ const data = new DataTransfer ( ) ;
103+ data . items . add ( new File ( [ await request . blob ( ) ] , 'image.png' ) ) ;
104+ fileInput . files = data . files ;
105+ fileInput . dispatchEvent ( new Event ( 'change' ) ) ;
106+ } catch ( error ) {
107+ console . error ( 'Error fetching URL:' , url , error ) ;
108+ return ;
109+ }
101110 }
102111 }
103112
You can’t perform that action at this time.
0 commit comments