Reputation: 2381
I'm trying to open an XML file that is in the same folder of my controller. I have the files:
controllers/test/myController.js controllers/test/myXML.xml
The myXML.xml:
<?xml version="1.0"?>
<something>
</something>
myController.js file:
exports.getXML = async (req, res, next) => {
const xmlFile = fs.readFileSync('./myXML.xml', 'utf8');
console.log(xmlFile);
}
I'm getting the error:
UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open './myXML.xml'
I tried to change './myXML.xml' to 'myXML.xml' and I also get the same error.
Upvotes: 0
Views: 151