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

Categories

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格式不是应该数组直接传递的吗?谢谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...