Class: ServerVariables
A collection of server variables defined in dedicated server configuration.
Example
import { variables, secrets } from "@minecraft/server-admin";
import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from "@minecraft/server-net";
const serverUrl = variables.get('serverEndpoint');
function getPlayerProfile(playerId: string): Promise<HttpResponse> {
const req = new HttpRequest(serverUrl + 'getPlayerProfile');
req.body = JSON.stringify({
playerId,
});
const authTokenSec = secrets.get('authtoken');
if (!authTokenSec) {
throw new Error('authtoken secret not defined.');
}
req.method = HttpRequestMethod.Post;
req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)];
return http.request(req);
}
getPlayerProfile('dark navi');
Constructors
new ServerVariables()
private
new ServerVariables():ServerVariables
Returns
Properties
names
readonly
names:string
[]
Remarks
A list of available, configured server variables.
Methods
get()
get(
name
):any
Parameters
Parameter | Type |
---|---|
name | string |
Returns
any
Remarks
Returns the value of variable that has been configured in a dedicated server configuration JSON file.
This function can't be called in read-only mode.