前端axios发送请求,后端nodejs接收请求,并与java中spring boot的注释进行对应
req.body(类似于@RequestBody)
const params = new URLSearchParams();
params.append('uid',uuidv4())
params.append('name',this.name)
params.append('description',this.description)
params.append('date',utils.formatDate(new Date()))
this.$axios.post('/api/test',params)
let name = req.body.name
req.query(类似于@PathVariable)
this.$axios.get('/api/test',{
params:{
uid:row.uid
}
})
let uid = req.query.uid;
formidable(类似于@RequestParam)
let form=new FormData()
form.append("id",this.id)
form.append("oid",this.oid))
form.append("name",this.name)
this.$axios.post('/api/test/',form)
var form =new formidable.IncomingForm()
form.parse(req,(err,fields,files)=>{
let id = fields.id;
let oid = fields.oid;
let name = fields.name;
}