File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -70,17 +70,23 @@ async function fetchResults(remoteInput: RemoteInputElement, checkCurrentQuery:
7070
7171 remoteInput . dispatchEvent ( new CustomEvent ( 'loadstart' ) )
7272 remoteInput . setAttribute ( 'loading' , '' )
73+ let response , html
7374 try {
74- const response = await fetch ( url , {
75+ response = await fetch ( url , {
7576 credentials : 'same-origin' ,
7677 headers : { accept : 'text/html; fragment' }
7778 } )
78- const html = await response . text ( )
79+ html = await response . text ( )
7980 remoteInput . dispatchEvent ( new CustomEvent ( 'load' ) )
80- resultsContainer . innerHTML = html
8181 } catch {
82+ // noop
83+ }
84+ if ( response && response . ok && html ) {
85+ resultsContainer . innerHTML = html
86+ } else {
8287 remoteInput . dispatchEvent ( new CustomEvent ( 'error' ) )
8388 }
89+
8490 remoteInput . removeAttribute ( 'loading' )
8591 remoteInput . dispatchEvent ( new CustomEvent ( 'loadend' ) )
8692}
You can’t perform that action at this time.
0 commit comments