I am aware that this error means "Cannot find file," howevever, I have this code copy and pasted, with an almost identical file scheme, and it works in one project and not the other.
The code I have is as follows...
var req = request.post({encoding: null, url: 'https://pdftables.com/api?key=770oukvvx1wl&format=xlsx-single'}, function (err, resp, body) {
if (!err && resp.statusCode == 200) {
fs.writeFile("output.xlsx", body, function(err) {
if (err) {
console.log('error writing file');
}
});
} else {
console.log('error retrieving URL');
console.log(err)
console.log(resp.statusCode)
};
});
var form = req.form();
form.append('file', fs.createReadStream('./TOM_Sample_ScoreCard.pdf'));
Given that this is being run from a file in the same directory as the pdf, TOM_Sample_ScoreCard.pdf I don't see why I am getting this error.
UPDATE:
I moved both this file as well as the pdf further towards the outside of the directory tree, and it sent back the appropriate response... I am unsure how exactly the file organization effected this but hopefully this helps someone else
I am aware that this error means "Cannot find file," howevever, I have this code copy and pasted, with an almost identical file scheme, and it works in one project and not the other. The code I have is as follows...
Given that this is being run from a file in the same directory as the pdf,
TOM_Sample_ScoreCard.pdf
I don't see why I am getting this error.UPDATE: I moved both this file as well as the pdf further towards the outside of the directory tree, and it sent back the appropriate response... I am unsure how exactly the file organization effected this but hopefully this helps someone else