Comment afficher une alerte d'erreur en frontend lors d'une requête Ajax ?

Je ne suis pas sûr du contexte général, mais je crois que vous pouvez faire ceci :

import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";

try {
  // ...
} catch (e) {
  popupAjaxError(e);
}

// OU
ajax("...") // Une fonction
  .then(() => {
    // ...
  })
  .catch(popupAjaxError);
1 « J'aime »