Don't parse JSON files as actual JSON
This commit is contained in:
parent
0f8dcabb45
commit
37715762cd
|
@ -1,11 +1,20 @@
|
||||||
import http from "@/api/http";
|
import http from "@/api/http";
|
||||||
|
import {AxiosError} from "axios";
|
||||||
|
|
||||||
export default (server: string, file: string): Promise<string> => {
|
export default (server: string, file: string): Promise<string> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
http.get(`/api/client/servers/${server}/files/contents`, {
|
http.get(`/api/client/servers/${server}/files/contents`, {
|
||||||
params: { file }
|
params: { file },
|
||||||
|
responseType: 'text',
|
||||||
|
transformResponse: res => res,
|
||||||
})
|
})
|
||||||
.then(response => resolve(response.data))
|
.then(response => resolve(response.data || ''))
|
||||||
.catch(reject);
|
.catch((error: AxiosError) => {
|
||||||
|
if (error.response && error.response.data) {
|
||||||
|
error.response.data = JSON.parse(error.response.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue