loading file into text editor
This commit is contained in:
@@ -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);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user