Wix fetch() large xml data

Hi, i am looking at coding an XML data feed into property website.

The company has an XML feed that is rather large. (over 7mb). I have done a search and tried multiple ways to achieve this and while the code looks like it works and it reads sitemaps it just will not load up the property data i need it to.

I have created a backend file for this to work and imported the XML parser module. Can someone help me out.

https://help.kyero.com/estate-agents/xml-import-specification

import { fetch, getJSON } from 'wix-fetch';
import parser from 'fast-xml-parser';
// ...
export function getProps() {
console.log('starting')
fetch("https://www.spanishpropertychoice.com/xml/kyero_v3_exc_imp_all.xml", { "method": "get" })
.then((httpResponse) => {
console.log('httpResponse', httpResponse.text())
let url = httpResponse.url;
let statusCode = httpResponse.status;
let statusText = httpResponse.statusText;
let headers = httpResponse.headers;
let bodyUsed = httpResponse.bodyUsed;
if (httpResponse.ok) {
return httpResponse.text().then((x) => {
let xml
xml = String(x);
xml = parser.parse(xml);
console.log('xxxx', xml)
})
} else {
return Promise.reject("Fetch did not succeed");
}
})
.then((json) => {
console.log('json key', json.someKey);
})
.catch((err) => {
console.log('err', err);
});
}

export function getProps1() {
console.log('starting')
let xml
let url = "https://www.spanishpropertychoice.com/xml/kyero_v3_exc_imp_all.xml";
return fetch(url, {
method: 'get',
headers: { 'Content-Type': 'application/XML' }
})
.then((httpResponse) => {
console.log('first then') //THIS IS AS FAR AS THE CONSOLE SPITS OUT
httpResponse.text().then((response) => {
console.log('second then')
xml = String(response);
xml = parser.parse(xml);
console.log("xml: ", xml);
return xml;
})
});
}

//THIS ONE WORKS IF I USE MY SITEMAP BUT IF I USE THE REAL URL IT JUST PRINTS OUT STARTING AND THATS IT.
export function getProps2() {
let url = "https://www.tw-webdesigns.com/sitemap.xml";
console.log('starting')
fetch(url, { method: 'get' })
.then(httpResponse => httpResponse.text())
.then(text => console.log(text));
}

this is the front end code, its just a button click

// For full API documentation, including code examples, visit https://wix.to/94BuAAs
import { getProps, getProps1, getProps2 } from 'backend/getProp.jsw';

$w.onReady(function () {
//TODO: write your page related code here...
});

export function button1_click(event) {
//getProps1()
getProps2()
//getProps()
}

2 Likes

Is there not anyone that can help me?

Did you ever figure this out?