forked from JaylyDev/ScriptAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecrets.js
More file actions
26 lines (21 loc) · 689 Bytes
/
secrets.js
File metadata and controls
26 lines (21 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { secrets } from "@minecraft/server-admin";
import { http, HttpRequest, HttpRequestMethod, HttpHeader } from "@minecraft/server-net";
const req = new HttpRequest("https://localhost:8080/api/");
req.body = JSON.stringify({
playerId: 'johndoe',
});
req.method = HttpRequestMethod.POST;
req.headers = [
new HttpHeader('Content-Type', 'application/json'),
new HttpHeader('auth', secrets.get('authtoken')),
];
http.request(req).then(res => {
// Do something with the response.
const { body, headers, request, status } = res;
console.warn(body);
console.warn(headers);
console.warn(request);
console.warn(status);
}).catch(err => {
console.error(err);
});