2019-05-25 23:24:13 +00:00
|
|
|
import http from "@/api/http";
|
2019-06-01 21:24:00 +00:00
|
|
|
import {AxiosError} from "axios";
|
2019-05-25 23:24:13 +00:00
|
|
|
|
|
|
|
export default (server: string, file: string): Promise<string> => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
http.get(`/api/client/servers/${server}/files/contents`, {
|
2019-06-01 21:24:00 +00:00
|
|
|
params: { file },
|
|
|
|
responseType: 'text',
|
|
|
|
transformResponse: res => res,
|
2019-05-25 23:24:13 +00:00
|
|
|
})
|
2019-06-01 21:24:00 +00:00
|
|
|
.then(response => resolve(response.data || ''))
|
|
|
|
.catch((error: AxiosError) => {
|
|
|
|
if (error.response && error.response.data) {
|
|
|
|
error.response.data = JSON.parse(error.response.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
reject(error);
|
|
|
|
});
|
2019-05-25 23:24:13 +00:00
|
|
|
});
|
|
|
|
}
|