@minecraft
    正在准备搜索索引...

    类 HttpHeader

    表示一个请求标头,即包含了请求元数据的键值对。

    Represents an HTTP header - a key/value pair of meta-information about 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);
    }
    索引

    构造函数

    属性

    构造函数

    属性

    key: string

    请求标头的键。

    Key of the HTTP header.

    value: string | SecretString

    请求标头的值。

    Value of the HTTP header.