Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
How to get file from URL or FTP into variable using Cloudflare Worker?

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!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda