I try to fetch data from URL link in VUE, the link response XML data in the browser but, when I try to retrieve the data in the code I get CORS error:
fetch(
'https://www.treasury.gov/resource-center/data-chart-center/interest-rates/Datasets/yield.xml',
{
method: 'GET',
headers: {
'Content-Type': 'text/xml',
},
}
)
.then((response) => {
console.log(response);
response.text();
})
.then((data) => {
const parser = new DOMParser();
const xml = parser.parseFromString(data, 'application/xml');
console.log(xml);
})
.catch(console.error);