I am unable to read PDF file in node js.
My code looks like this:
var router = express.Router();
router.get('/api/resource', function(req, res) {
filePath = req.query.resource;
fs.readFile(filePath, function(err, file) {
res.writeHead(200, {"Content-Type" : "application/pdf" });
res.write(file, "binary");
res.end();
});
});
But i am not able to get the content of the file in the response.