node.js - function in a function return value -


import.js

exports.getconfig = function() {   return api.getconfig();  }; 

test.js

// aanmaken lightbridge obj = reflector.getobj(); console.log(obj);  // toon alle lichten obj.getconfig().then(function(config) {     console.log(config); }).done(); 

in last snippet it's using function of when call getconfig() want have output in variable config. problem when want log variable test recieve undefined.

if console.log(config) instead of return config; works perfectly. seems weird.

the out result when want use varia.getconfig() => output of config.

test exist on function not outside. can try may dirty.

    var test;     exports.getconfig = function() {       api.getconfig(function(err, config) {         if (err) throw err;         test = config;     }); 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -