@minecraft/server-net
    Preparing search index...

    Class HttpRequestBeta

    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);
    }
    Index

    Constructors

    • Beta

      Parameters

      • uri: string

      Returns HttpRequest

    Properties

    body: string

    Content of the body of the HTTP request.

    This property can be edited in early-execution mode.

    headers: HttpHeader[]

    A collection of HTTP headers to add to the outbound request.

    This property can be edited in early-execution mode.

    HTTP method (e.g., GET or PUT or PATCH) to use for making the request.

    This property can be edited in early-execution mode.

    timeout: number

    Amount of time, in seconds, before the request times out and is abandoned.

    This property can be edited in early-execution mode.

    uri: string

    The HTTP resource to access.

    This property can be edited in early-execution mode.

    Methods

    • Beta

      Parameters

      • key: string
      • value: string | SecretString

      Returns HttpRequest

      Adds an additional header to the overall list of headers used in the corresponding HTTP request.

      This function can be called in early-execution mode.

    • Beta

      Parameters

      • body: string

      Returns HttpRequest

      Updates the content of the body of the HTTP request.

      This function can be called in early-execution mode.

    • Beta

      Parameters

      Returns HttpRequest

      Replaces and applies a set of HTTP Headers for the request.

      This function can be called in early-execution mode.

    • Beta

      Parameters

      Returns HttpRequest

      Sets the desired HTTP method (e.g., GET or PUT or PATCH) to use for making the request.

      This function can be called in early-execution mode.

    • Beta

      Parameters

      • timeout: number

      Returns HttpRequest

      This function can be called in early-execution mode.