loading file into text editor

This commit is contained in:
2024-09-13 21:00:08 +00:00
parent 437701ffac
commit faa45f7fcf
6 changed files with 97 additions and 36 deletions

View File

@@ -1,3 +1,4 @@
import { get } from "http";
import { File } from "./interfaces";
export default function files(pterodactyl: any) {
@@ -57,5 +58,24 @@ export default function files(pterodactyl: any) {
console.error("Error fetching data:", error);
}
},
async getContent(filename: string) {
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_URL}/api/client/servers/${pterodactyl.server_id}/files/contents?file=${filename}`,
{
method: "GET",
headers: await pterodactyl.helpers.authHeader(),
}
);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.text();
return data;
} catch (error) {
console.error("Error fetching data:", error);
}
},
};
}