Skip to content

Commit 7981da7

Browse files
committed
fix(index.js): Add status=500 context
1 parent b6b5329 commit 7981da7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/common/actions/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,16 @@ export function secureFetch (url: string, method: string = 'get', payload?: any,
5454
const {status} = res
5555
if (status >= 500) {
5656
action = 'RELOAD'
57-
message = `Network error!\n\n(${method} request on ${url})`
58-
consoleError(message)
59-
dispatch(setErrorMessage({message, action}))
57+
res.json().then(json => {
58+
const {detail, message} = json
59+
const unknown = `Network error!\n\n(${method} request on ${url})`
60+
consoleError(message || JSON.stringify(json) || unknown)
61+
dispatch(setErrorMessage({
62+
message: message || JSON.stringify(json) || unknown,
63+
action,
64+
detail
65+
}))
66+
})
6067
return null
6168
} else if (status >= 400) {
6269
action = status === 401

0 commit comments

Comments
 (0)