Have been doing quite a bit of work with this RPC API as of late, and am having some major trouble with updating variables from within them. I am quite new to js, and have been doing this like a newbie for too long.Would anyone be willing to show me how these should be worked with?
let x = '';
rpc.api.getConfig(function(err, resp) {
console.log(err, resp);
x = result;
});
console.log(x); //COMES UP EMPTY :(
Though if I set a timeout on the log, it will show after a few seconds. I know this is because I do not receive the response right away, but am having major trouble turning this into a promise, or any other solution I can think of lol.
Would greatly appreciate your help.