express + formidable 获取前台传送的数据请求

2019-02-19  本文已影响0人  vioi
var express = require('express');
var app = express();
var formidable = require('formidable');


app.get("/list",function(req,res){
    var form = new formidable.IncomingForm();
    form.parse(req,(err,fields,files)=>{
        console.log(req.query);//针对get请求
        console.log(fields);//针对post请求
        res.header("Access-Control-Allow-Origin","*");
        res.json({
            "id":"170",
            "name":'xioaming',
            "age":"19"
        })
    })
 

})
app.listen(3000)
console.log('服务器开始运行!')
上一篇下一篇

猜你喜欢

热点阅读