This is a simple library implementation for Grakkit (or other GraalVM implementations within Minecraft) providing fetch functionality.
- Add library file to your grakkit folder, such as
./plugins/grakkit
- Add the following:
// Loads the jar
const FetchClient = core.load('./plugins/grakkit/fetchClient.jar', 'fetch.FetchClient')
const client = new FetchClient()
// Adds the plugin; needed to fix async issues
client.setPlugin(core.plugin)
- Once declared, you can start using it.
// Example
console.log((await client.fetch('https://api.publicapis.org/entries', 'GET', '', [])).body())
There are a total of four parameters (all required).
- URL: This is the target URL.
- Method: This is 'GET', 'POST', etc.
- Payload: This is the string payload. For empty, you can do
''
. - Headers: This accepts headers in an flat array.
- Example:
['Content-Type', 'application/json; charset=utf-8']
- Example:
- Clone repo locally.
- Run
./gradlew shadowJar