Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.8k views
in Technique[技术] by (71.8m points)

请教express post的问题

const express = require('express')
const cors = require('cors')
const app=express()
var bodyParser=require("body-parser");
app.use(bodyParser.urlencoded({extended:false}))
app.use(bodyParser.json())
app.use(cors())
app.use(express.static('public'))
app.post('/test',function (req, res) {
  const s=req.body
 console.log(s)
  const {sites1}=s

 res.send(sites1)
  }
app.listen(3005,function (){console.log("localhost:3005")})

postman在body里的www-form-urlencoded里发送请求,key:sites1,value:["1001"]
为什么后端打印出来的是[Object: null prototype] { sites1: '["1001"]' }
为什么有[Object: null prototype],而且["1001"]变成了字符串?传递JSON格式不是应该数组直接传递的吗?谢谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...