fix: Correctly parse XML response from CORS proxy in RSS ticker
This commit is contained in:
@@ -73,13 +73,13 @@
|
|||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log('Proxy response:', response);
|
console.log('Proxy response:', response);
|
||||||
if (response.ok) return response.json();
|
if (response.ok) return response.text();
|
||||||
throw new Error('Network response was not ok.');
|
throw new Error('Network response was not ok.');
|
||||||
})
|
})
|
||||||
.then(data => {
|
.then(xmlText => {
|
||||||
console.log('Raw data from proxy:', data);
|
console.log('Raw XML from proxy:', xmlText);
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const xmlDoc = parser.parseFromString(data.contents, "text/xml");
|
const xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
||||||
console.log('Parsed XML Doc:', xmlDoc);
|
console.log('Parsed XML Doc:', xmlDoc);
|
||||||
const items = xmlDoc.querySelectorAll("item");
|
const items = xmlDoc.querySelectorAll("item");
|
||||||
let headlines = [];
|
let headlines = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user