A
A
alexeylesin2020-05-21 18:18:35
Node.js
alexeylesin, 2020-05-21 18:18:35

How to render a variable in NodeJS?

I'm new to JS, making a status page for a minecraft server. I need to move the "gamever" variable outside of ping to use it later in the ejs file, how can I do that? (tried different ways, nothing worked)

const ping = require('minecraft-ping')

ping.ping_fe01fa({host:'play.kingnetwork.ru', port:25565}, function(err, response) {
  const gamever = (response.gameVersion);
});

console.log(gamever);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stepan Krapivin, 2020-05-21
@alexeylesin

const ping = require('minecraft-ping')

let gamever

ping.ping_fe01fa({host:'play.kingnetwork.ru', port:25565}, function(err, response) {
  gamever = (response.gameVersion);
});

console.log(gamever);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question