The Fetch class simplifies HTTP requests in Minecraft Bedrock Edition. It supports common HTTP methods like GET, POST, PUT, and DELETE, and automatically handles JSON data.
- Initializes a new
Fetchinstance with the specified base URL.
- Sends an HTTP
GETrequest to the specified path with optional query parameters.
- Sends an HTTP
POSTrequest to the specified path with the provided data.
- Sends an HTTP
PUTrequest to the specified path with the provided data.
- Sends an HTTP
DELETErequest to the specified path.
import { Fetch } from './fetch.js';
// Initialize Fetch instance
const api = new Fetch("https://jsonplaceholder.typicode.com");
// GET example
api.get("/posts", { userId: 1 }).then((data) => console.log(data));
// POST example
api.post("/posts", {
title: "foo",
body: "bar",
userId: 1
}).then((data) => console.log(data));
// PUT example
api.put("/posts/1", {
title: "updated title",
body: "updated body",
userId: 1
}).then((data) => console.log(data));
// DELETE example
api.delete("/posts/1").then((data) => console.log(data));These scripts were written by nperma