mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-07 03:01:33 +00:00
Display a JS alert if /admin/search/known_users returns an error
This commit is contained in:
committed by
Maikel Linke
parent
50265780cf
commit
1554459eb9
@@ -1,5 +1,6 @@
|
||||
import { Controller } from "stimulus";
|
||||
import TomSelect from "tom-select/dist/esm/tom-select.complete";
|
||||
import showHttpError from "js/services/show_http_error";
|
||||
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
@@ -25,7 +26,13 @@ export default class extends Controller {
|
||||
#load(query, callback) {
|
||||
const url = "/admin/search/known_users.json?q=" + encodeURIComponent(query);
|
||||
fetch(url)
|
||||
.then((response) => response.json())
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
showHttpError(response.status);
|
||||
throw response;
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then((json) => {
|
||||
callback({ items: json });
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user