I'm trying to retrieve XML data from the URL below with Javascript and later parse the data I want from it. I've set up the fetch request below. My browser shows I'm receiving the yield.xml file, but I'm not able to access it. Instead, I get the error:
scripts.js:149 Uncaught (in promise) TypeError: Cannot read property 'getElementsByTagName' of undefined
at scripts.js:149
(anonymous) @ scripts.js:149
Any help would be appreciated
function yield() {
var url = "https://www.treasury.gov/resource-center/data-chart-center/interest-rates/Datasets/yield.xml";
var myHeaders = new Headers();
myHeaders.append('Content-Type', 'text/plain');
fetch(url, {
headers: myHeaders,
mode: "no-cors",
}).then(function(response) {
console.log(response);
var xmlDoc = response.responseXML;
var bc1month = xmlDoc.getElementsByTagName("BC_1MONTH").nodeValue;
console.log(bc1month);
});
}