【发布时间】:2022-01-21 06:58:39
【问题描述】:
我编写了一个代码来读取 json 文件并将其打印到浏览器。代码工作正常,它在控制台上打印数据。但没有上浏览器。
app.post("/uploadfile",function (req, res, next) {
// Error MiddleWare for multer file upload, so if any
// error occurs, the image would not be uploaded!
upload(req,res,function(err) {
if(err) {
res.send(err)
}
else {
//res.sendFile(__dirname+"/result.html")
// Read users.json file
fs.readFile(__dirname+"/uploads/zipFile.json", function(err, data) {
// Check for errors
if (err) throw err;
// Converting to JSON
const msg = JSON.parse(data);
console.log(msg)
app.post('/', function(req, res){
res.send(msg);
【问题讨论】:
标签: javascript node.js json web-deployment nodejs-server