Skip to content

Commit 6a41e85

Browse files
committed
Use content negotiation hint to identify requests
Allow the server to reply with a response body unique to remote-input requests by sending an Accept header hint in the request. A partial HTML fragment might be returned rather than a full page.
1 parent 20a0f05 commit 6a41e85

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async function fetchResults(remoteInput: RemoteInputElement, checkCurrentQuery:
7171
remoteInput.dispatchEvent(new CustomEvent('loadstart'))
7272
remoteInput.setAttribute('loading', '')
7373
try {
74-
const response = await fetch(url)
74+
const response = await fetch(url, {headers: {accept: 'text/html; fragment'}})
7575
const html = await response.text()
7676
remoteInput.dispatchEvent(new CustomEvent('load'))
7777
resultsContainer.innerHTML = html

0 commit comments

Comments
 (0)