Skip to content

Commit

Permalink
Reload page when we get a 401 back from bcapp
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwiese committed Oct 4, 2024
1 parent 4bf03ca commit 82fef93
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,18 @@ export default function (relativeUrl, opts, callback) {

return fetch(url, config)
.then((response) => {
if (response.headers.get('content-type').indexOf('application/json') !== -1) {
return response.json();
let result = null;

if (response.status === 401 && response.headers.get('X-BC-Preview-Mode').indexOf('true') !== -1) {
window.location.reload();
} else if (response.headers.get('content-type').indexOf('application/json') !== -1) {
result = response.json();
} else {
result = response.text();
}
return response.text();
})
.then((response) => {

return result;
}).then((response) => {
const content = options.remote ? response.content : response;
let ret = response;

Expand Down

0 comments on commit 82fef93

Please sign in to comment.