From 2b4e162b1d50e6727304bdcb8406c244764cb2e2 Mon Sep 17 00:00:00 2001 From: Mozafar Haider Date: Tue, 12 Dec 2023 09:37:32 +0000 Subject: [PATCH] fix(DHIS2-15304): display correct error message when session is expired --- src/api.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/api.js b/src/api.js index 1c8efe0..cc15901 100644 --- a/src/api.js +++ b/src/api.js @@ -1,4 +1,5 @@ import { useConfig } from '@dhis2/app-runtime' +import i18n from '@dhis2/d2-i18n' class Api { constructor({ baseUrl }) { @@ -10,7 +11,15 @@ class Api { method, body, credentials: 'include', + redirect: 'manual', }).then(async (res) => { + if (res.type === 'opaqueredirect') { + throw { + message: i18n.t( + 'Your session has expired. Please refresh the page and login before trying again.' + ), + } + } if (res.status < 200 || res.status >= 300) { const errorBody = await res.json() throw errorBody