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:
70
70
71
71
remoteInput . dispatchEvent ( new CustomEvent ( 'loadstart' ) )
72
72
remoteInput . setAttribute ( 'loading' , '' )
73
+ let response , html
73
74
try {
74
- const response = await fetch ( url , {
75
+ response = await fetch ( url , {
75
76
credentials : 'same-origin' ,
76
77
headers : { accept : 'text/html; fragment' }
77
78
} )
78
- const html = await response . text ( )
79
+ html = await response . text ( )
79
80
remoteInput . dispatchEvent ( new CustomEvent ( 'load' ) )
80
- resultsContainer . innerHTML = html
81
81
} catch {
82
+ // noop
83
+ }
84
+ if ( response && response . ok && html ) {
85
+ resultsContainer . innerHTML = html
86
+ } else {
82
87
remoteInput . dispatchEvent ( new CustomEvent ( 'error' ) )
83
88
}
89
+
84
90
remoteInput . removeAttribute ( 'loading' )
85
91
remoteInput . dispatchEvent ( new CustomEvent ( 'loadend' ) )
86
92
}
You can’t perform that action at this time.
0 commit comments