How to convert XML document to JSON using reactjs? I got response shown down below. I tried a lot of things and still nothing.
import React, { useEffect } from 'react'
function Api() {
useEffect(() => {
fetch("/author/list/18541?format=xml&key=TftQypHkudfH0VZcukEWtg")
.then(res => res.text())
.then(data => {
let parser = new DOMParser()
let xmlDoc = parser.parseFromString(data, 'text/xml')
console.log(xmlDoc)
})
.catch(err => console.log(err));
}, [])
return (
<div></div>
)
}
export default Api