简体   繁体   中英

sending multiple objects using axios

How can I send multiple objects in axios ? is there a way to send an array to an API using axios ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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