Using external Node libraries
Finding libraries
Using libraries in your code
import { parseString } from 'xml2js';
// Or use result of other steps, for example, HTTP request as const xml = {{data}}
const xml = `<note>
<to>User</to>
<from>Library</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>`;
return new Promise((resolve, reject) => {
parseString(xml, (err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
});require() imports
require() importsLast updated
Was this helpful?