Class in @minecraft/server-net
Makes HTTP requests. Use http.
import { HttpClient } from '@minecraft/server-net';Example
Section titled “Example”import { http, HttpError, type HttpResponse } from '@minecraft/server-net';
async function fetchStatus(): Promise<void> { try { const response: HttpResponse = await http.get('https://example.com/status.json'); console.log(response.status, response.body); } catch (error) { if (error instanceof HttpError) console.warn(`Request failed: ${error.reason}`); else throw error; }}
fetchStatus();import { http, HttpError } from '@minecraft/server-net';
async function fetchStatus() { try { const response = await http.get('https://example.com/status.json'); console.log(response.status, response.body); } catch (error) { if (error instanceof HttpError) console.warn(`Request failed: ${error.reason}`); else throw error; }}
fetchStatus();Methods
Section titled “Methods”cancelAll
Section titled “cancelAll”cancelAll(reason: string): void;Abandons every request in flight; their promises reject with reason as the message.
Parameters
reasonstring
get(uri: string): Promise<HttpResponse>;A GET request for uri.
Parameters
uristring
Returns
Promise<HttpResponse>Types
request
Section titled “request”request(config: HttpRequest): Promise<HttpResponse>;Sends a request, resolving with its answer whatever the status, or rejecting with an
HttpError when none comes.
Parameters
configHttpRequest
Returns
Promise<HttpResponse>