access variable after define it inside a function
<p>I'm trying to access a variable outside a function, but I'm getting undefined</p>

<pre><code> meliObject.get('users/me', function (err, res) {
           nickname = res.nickname;
  });

console.log(nickname);
</code></pre>

<p>How can I access nickname?</p>

<p>EDIT</p>

<p>I changed my code for:</p>

<pre><code>var nickname;

        meliObject.get('users/me', function (err, res) {

            nickname = res.nickname;


        });

        console.log(nickname);
</code></pre>

<p>But I'm still getting undefined</p>