|
|
@@ -41,13 +41,17 @@ class Connector {
|
|
41
|
41
|
async _tryFetch({ endpoint, header }, returnHeaders = false) {
|
|
42
|
42
|
try {
|
|
43
|
43
|
const res = await fetch(`${remote}${endpoint}`, header)
|
|
|
44
|
+ const jsonRes = await res.json()
|
|
44
|
45
|
if (!res.ok) {
|
|
45
|
|
- throw Error(res.statusText)
|
|
|
46
|
+ if (res.status === 401) {
|
|
|
47
|
+ return { ...jsonRes.data, status: res.status }
|
|
|
48
|
+ } else {
|
|
|
49
|
+ throw Error(res.statusText)
|
|
|
50
|
+ }
|
|
46
|
51
|
}
|
|
47
|
52
|
if (returnHeaders) {
|
|
48
|
53
|
return res.headers
|
|
49
|
54
|
} else {
|
|
50
|
|
- const jsonRes = await res.json()
|
|
51
|
55
|
return jsonRes.data
|
|
52
|
56
|
}
|
|
53
|
57
|
} catch (error) {
|