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

    Class HttpClientBeta

    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

    Methods

    • Beta

      Parameters

      • reason: string

      Returns void

      Cancels all pending requests.

      This function can be called in early-execution mode.

    • Beta

      Parameters

      • uri: string

        URL to make an HTTP Request to.

      Returns Promise<HttpResponse>

      An awaitable promise that contains the HTTP response.

      Performs a simple HTTP get request.

      This function can be called in early-execution mode.

    • Beta

      Parameters

      • config: HttpRequest

        Contains an HTTP Request object with configuration data on the HTTP request.

      Returns Promise<HttpResponse>

      An awaitable promise that contains the HTTP response.

      Performs an HTTP request.

      This function can be called in early-execution mode.

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