Main object for structuring a request.
import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net';async function updateScore() { const req = new HttpRequest('http://localhost:3000/updateScore'); req.body = JSON.stringify({ score: 22, }); req.method = HttpRequestMethod.Post; req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', 'my-auth-token')]; await http.request(req);} Copy
import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net';async function updateScore() { const req = new HttpRequest('http://localhost:3000/updateScore'); req.body = JSON.stringify({ score: 22, }); req.method = HttpRequestMethod.Post; req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', 'my-auth-token')]; await http.request(req);}
Early execution
Content of the body of the HTTP request.
A collection of HTTP headers to add to the outbound request.
HTTP method (e.g., GET or PUT or PATCH) to use for making the request.
Amount of time, in seconds, before the request times out and is abandoned.
The HTTP resource to access.
Adds an additional header to the overall list of headers used in the corresponding HTTP request.
Updates the content of the body of the HTTP request.
Replaces and applies a set of HTTP Headers for the request.
Sets the desired HTTP method (e.g., GET or PUT or PATCH) to use for making the request.
The timeout value, in seconds.
Sets the maximum amount of time, in seconds, before the request times out and is cancelled.
Main object for structuring a request.
Example: simpleHttpRequest.ts