Skip to content

Instantly share code, notes, and snippets.

@Philip-Nunoo
Last active May 7, 2019 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Philip-Nunoo/85357e0dd09293aeecc5105922a110f1 to your computer and use it in GitHub Desktop.
Save Philip-Nunoo/85357e0dd09293aeecc5105922a110f1 to your computer and use it in GitHub Desktop.
// Using axios and fast-xml-parser you can retrieve the data received as xml and converted to json object.
import axios from 'axios';
var fastXmlParser = require('fast-xml-parser');
let jsonObj = {};
axios.get('https://virgool.io/feed/@jEbrahimi')
.then(xml => xml.data)
.then(xmlText => {
if (fastXmlParser.validate(xmlText)) {
jsonObj = fastXmlParser.parse(xmlText);
console.log(jsonObj.feed);
}
})
.catch((e) => console.error('Error in fetching the website', e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment