How does vue use axios to pass an array of objects to the background? And the background can receive this object? (node+express in the background)

I now have an array of objects, such as the following format:

let objArray = [
    {name: "Amy", age: "n", age: 18},
    {name: "Amy", age: "n", age: 18},
    {name: "Amy", age: "n", age: 18},
    {name: "Amy", age: "n", age: 18}
]

I use qs.stringfy () to transcode the object, and then parse it with qs.parse () in the background of node to get the following format

{ "0": { name: "Amy", age: "18" },
  "1": { name: "Amy", age: "18" },
  "2": { name: "Amy", age: "18" },  
  "3": { name: "Amy", age: "18" } }
}

the main functions I want to achieve are:

  • the front end sends an array of objects, and the node server stores the array of objects (transcoded into json strings) in the database
  • After
  • , the server can return this data, and the foreground can get the same array of objects as before
Jun.14,2022

try JSON.stringify and JSON.parse?


Hello, I have a similar problem with you. I use qs.parse to ensure that when the front end (the data structure of the array containing objects) is passed to the background, the accepted data is the original data structure, but the strange thing is that there are more fields such as uid statu. I hope it can help you


I wonder if you want to convert the backend object to array

.
var data = { '0': { name: 'Amy', age: '18' },
  '1': { name: 'Amy', age: '18' },
  '2': { name: 'Amy', age: '18' },  
  '3': { name: 'Amy', age: '18' }
}
var arr = Object.keys(data).map(key=> data[key]);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e75852-4da33.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e75852-4da33.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?