mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00:00
Swap from request to got
This commit is contained in:
parent
67563c0f1e
commit
487b17dd73
9 changed files with 215 additions and 340 deletions
|
|
@ -2,15 +2,15 @@ const Core = require('./core');
|
|||
|
||||
class Terraria extends Core {
|
||||
async run(state) {
|
||||
const body = await this.request({
|
||||
uri: 'http://'+this.options.address+':'+this.options.port+'/v2/server/status',
|
||||
qs: {
|
||||
const json = await this.request({
|
||||
url: 'http://'+this.options.address+':'+this.options.port+'/v2/server/status',
|
||||
searchParams: {
|
||||
players: 'true',
|
||||
token: this.options.token
|
||||
}
|
||||
},
|
||||
responseType: 'json'
|
||||
});
|
||||
|
||||
const json = JSON.parse(body);
|
||||
if(json.status !== '200') throw new Error('Invalid status');
|
||||
|
||||
for (const one of json.players) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue