Skip to content

Commit cbb25b5

Browse files
authored
fix(api): parse response data for v1 (#482)
1 parent 86904fe commit cbb25b5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/api/interceptor.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import type { AxiosRequestConfig, AxiosResponse } from 'axios'
55
import { Message, Modal } from '@arco-design/web-vue'
66
import { RecordsType } from '@/store/modules/code-run/types'
77

8-
const { CancelToken } = axios
9-
108
export interface OutputType {
119
affectedrows: number
1210
records: RecordsType
@@ -122,11 +120,21 @@ axios.interceptors.response.use(
122120
},
123121

124122
(error) => {
123+
const isV1 = !!error.config.url?.startsWith(`/v1`)
124+
125125
if (error.response.status === 401) {
126126
const appStore = useAppStore()
127127
appStore.updateSettings({ globalSettings: true })
128128
}
129129

130+
if (isV1) {
131+
try {
132+
error.response.data = JSON.parse(error.response.data)
133+
} catch (e) {
134+
//
135+
}
136+
}
137+
130138
const { data } = error.response
131139

132140
const isInflux = !!error.config.url?.startsWith(`/v1/influxdb`)

0 commit comments

Comments
 (0)