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);
}
});
});
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
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);
}
})
})