1.浏览器默认方式form-urlencodes
2.json请求
后面设置请求参数
app.use(function(req, res, next){
//设置跨域访问
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild');
res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
if (req.method == 'OPTIONS') {
res.send(200); /*让options请求快速返回*/
}else {
next();
}
})
设置跨域请求头