I am trying to get the data from a KML file that is downloaded via one of the following two URLs:
https://ftp.cpc.ncep.noaa.gov/GIS/us_tempprcpfcst/ (specifically the seaskmls_latest.zip files) or https://www.cpc.ncep.noaa.gov/products/predictions/30day/lead14_temp.kml
The problem that I am having is that I need to get data from one of these sources into a variable in a Cloudflare Worker in order to process it and send it on to my React app. Once I have the data I am confident that I can do what I need but I have been unsuccessful in my attempts to get the data.
I have tried to use a basic fetch request from React (which didn't return any data)
fetch('https://www.cpc.ncep.noaa.gov/products/predictions/30day/lead14_temp.kml', { method: 'GET', mode: 'no-cors' })
.then(res => res.text());
I have tried using an XMLHttpRequest from React that I found in another thread (again, no dice)
function load(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) callback(xhr.responseText);
};
xhr.open("GET", url, true);
}
load("https://www.cpc.ncep.noaa.gov/products/predictions/30day/lead14_temp.kml", function (contents) {
console.log(contents);
});
And I have tried to use an FTP package (basic-ftp) from Cloudflare that I couldn't get to import properly due to dependency issues that I don't know how to resolve.
I feel like there is something basic here that I am missing. If anyone could point me in the correct direction or help me out with this I would be very grateful!