fix(ujs-error-handling): sometimes body is not yet ready,other calls regarding ajax namespace are wired on document, copy/paste
This commit is contained in:
parent
40df4bee84
commit
850f9375b7
1 changed files with 1 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
// For links and requests done through rails-ujs (mostly data-remote links),
|
||||
// redirect to the sign-in page when the server responds '401 Unauthorized'.
|
||||
document.body.addEventListener('ajax:error', (event) => {
|
||||
document.addEventListener('ajax:error', (event) => {
|
||||
const [, , xhr] = event.detail;
|
||||
if (xhr && xhr.status == 401) {
|
||||
location.reload(); // reload whole page so Devise will redirect to sign-in
|
||||
|
|
Loading…
Reference in a new issue