How can I store the content of a resolved promise in a variable : <p>I have a function that contains a promise. The function do an HTTP request and I want to resolve it and return the response as a value in a variable.</p>

<pre><code>function sendCommand(auth, playerId, command) {
    return new Promise((resolve, reject) =&gt; {
        request.post(`https://test.com/${playerId}/command`,{
            headers: { Authorization: auth },
            json: {
                "arg": `${command}`
            }
        }, function status(err, response, body) {
            if (response.statusCode === 200) {
                resolve(body)
            } else {
                reject(err)
            }
          }
        )  
    })
}
</code></pre>

<p>I run this function from a different file so I do the following: </p>

<pre><code>module.exports = {
    doSomething: (playerId, command) =&gt; {
        loginHelper.getToken().then(token =&gt;
        sendCommand(token, playerId, command))
    }
}
</code></pre>

<p>On the other file, I want to store the resolved response in a variable such as this:</p>

<pre><code>const commandHelper = require(__helpers + 'command-helper')

let test = commandHelper.doSomething(playerId, 'command')
</code></pre>

<p>I expect the test variable to contain response data.</p>
