How to pop up an error message in the front end with an Ajax request?

I’m not sure what the whole context is, but I believe you can do this:

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

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

// OR
ajax("...") // Some function
  .then(() => {
    // ...
  })
  .catch(popupAjaxError);
1 Like