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

183
Visualizações
ENOENT error on xml2js but file did exists

const xml2js = require('xml2js');
const fs = require('fs');

fs.readFile('https://www.tcmb.gov.tr/kurlar/today.xml', (err, data) => {
    if(err) console.log(err);
    var data = data.toString().replace("\ufeff", "");
    xml2js.parseStringPromise(data, (err, res) => {
        if(err){
            console.log(err);
        } else {
            console.log(res);
        }
    });
});
This is my code in nodejs I try to get data on a https link with xml2js first by using the way it says in the npm page pf xml2js it gives some error and when I chechk on web I find solution of using with fs but still geting this error enter image description here

I know the directory exists because if you go to link used in code it shows something but in code just gives error if someone can help I will be very happy

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

fs can only access file in your system, you should request the URL using http/https or even better try axios

const axios = require('axios')

axios.get('https://www.tcmb.gov.tr/kurlar/today.xml').then((response) => {
  const data = response.data
  xml2js.parseString(data, (err, res) => {
        if(err){
            console.log(err);
        } else {
            console.log(res);
        }
   })
})

about 4 years ago · Juan Pablo Isaza Relatório
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