diff --git a/resources/assets/scripts/api/server/files/getFileContents.ts b/resources/assets/scripts/api/server/files/getFileContents.ts index 4074721eb..f3a1f3d36 100644 --- a/resources/assets/scripts/api/server/files/getFileContents.ts +++ b/resources/assets/scripts/api/server/files/getFileContents.ts @@ -1,11 +1,20 @@ import http from "@/api/http"; +import {AxiosError} from "axios"; export default (server: string, file: string): Promise => { return new Promise((resolve, reject) => { http.get(`/api/client/servers/${server}/files/contents`, { - params: { file } + params: { file }, + responseType: 'text', + transformResponse: res => res, }) - .then(response => resolve(response.data)) - .catch(reject); + .then(response => resolve(response.data || '')) + .catch((error: AxiosError) => { + if (error.response && error.response.data) { + error.response.data = JSON.parse(error.response.data); + } + + reject(error); + }); }); }