Ask for JSON when autocompleting people to ping

`as: "json"` is a @rails/request.js option; plain fetch ignores it and
sends `Accept: */*`, so Autocompletable::UsersController answered with
its HTML format and response.json() threw. The new ping form never
showed any suggestions. Send an explicit Accept header instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sam Ruby
2026-10-04 20:06:53 -04:00
parent 254dd1d46f
commit b8be941b99
2 changed files with 16 additions and 1 deletions
@@ -120,7 +120,7 @@ export default class BaseAutocompleteHandler {
#fetchAutocompletables(url) {
if (url) {
return fetch(url, { as: "json" }).then(response => response.json())
return fetch(url, { headers: { Accept: "application/json" } }).then(response => response.json())
} else {
return Promise.resolve()
}