Last active
May 7, 2019 08:23
-
-
Save Philip-Nunoo/85357e0dd09293aeecc5105922a110f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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