Not able to figure out how to get data from an api having XML Content. I tried using axios,with JSON everything is clear. I want the data to be fetched from api on load and respective values to be filled in the form fields.
1 Answer
fetch(URL).then((results) => {
// results returns XML. Cast this to a string, then create
// a new DOM object out of it! like this
results
.text()
.then(( str ) => {
let responseDoc = new DOMParser().parseFromString(str, 'application/xml');
}
});
You can also use NPM module to parse XML.