Axios在POST上发送空对象

时间:2019-12-04 19:20:28

标签: javascript vue.js axios vuex

我具有以下功能:

const sendMyPhoto = ({ token, data }) => {
  console.log(typeof data) // Its returns: object
  console.log(data.length) // Its returns: 0
  console.log(data)
  /**
  its returns the correct data:
  [  0: {annoucements_id: "105", image: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD… 
  m2XmfQfRt68zSYlJyzaO5+yc/E2If3OITlHXo/qGvT1jon//Z"}
  1: {annoucements_id: "105", image: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD… 
 +cr5yvnK+cr5yvnK+cr5yuV85Xzlcr5yvnK+cr/FfOXP/2Q=="}
  length: 2
  __proto__: Array(0) ]
  **/
  return Http.post(`/api/vehicle/image/`, data, { headers: { Authorization: 'Bearer ' + token } })
}

这是我的网络标签: enter image description here

我不知道发生了什么。当console.log(data)返回正确的数据时,为什么data.length返回0,并且axios发送空数组。

0 个答案:

没有答案