简体   繁体   English

使用 axios 发送多个对象

[英]sending multiple objects using axios

How can I send multiple objects in axios ?如何在 axios 中发送多个对象? is there a way to send an array to an API using axios ?有没有办法使用 axios 将数组发送到 API?

This is the code.这是代码。

export const addOrderAdmin = (ownerID,array) => api.patch(`/checkout/${ownerID}`,
    {
        delivery: array // array with 2 objects. 
    }
)

and the objects was like this.对象是这样的。 在此处输入图像描述

is it possible ?可能吗 ?

you could always create an array of nested objects你总是可以创建一个嵌套对象数组

example:例子:

var customerInfo = {
  name: 'bob',
  phone : 'xxx-xxx-xxxx',
  address: [
   {
     id: 1,
     city: 'Buffalo'
   },
   {
     id 2,
     city: 'Houston'
  ]
}

then you could just patch the customerInfo object and you can use interpolation with dot accessor notation for the url然后你可以只修补 customerInfo 对象,你可以使用带有点访问器符号的插值作为 url

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM