Linked Questions

Popular Questions

How to retrieve data outside of function in Javascript?

Asked by At

I am using xml2js node module

I am parsing XML data into JSON

But how do I get the value outside this function?

var parseString = require('xml2js').parseString;

// My XML Data
var xml = "<root>my xml data</root>"

// Function to parse xml to json
parseString(xml, function (err, result) {

I am looking to get the parsed value result out of the function so that I can use it at different components?

const jsonOutput = result;

Related Questions