Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CrastyCrap's avatar

Pass array throw vue axios

greeting i have an array like the following

auction: [ auction_name: 'auction', auction_images: [{'id':1 , 'img': 'testsrc'}] ]

when i send it via axios the auction_images appear in that form

auction_images.0.id: 22
auction_images.0.img: http://127.0.0.1:8000/uploads/auctions/auction_1655464439.png
auction_images.1.id: 57
auction_images.1.img: http://127.0.0.1:8000/uploads/auctions/auction_1655725813.png
auction_images.2.id: 58
auction_images.2.img: http://127.0.0.1:8000/uploads/auctions/auction_1655725813_1.png
auction_images.3.id: 59
auction_images.3.img: http://127.0.0.1:8000/uploads/auctions/auction_1655727411.png
auction_images.4.id: 60
auction_images.4.img: http://127.0.0.1:8000/uploads/auctions/auction_1655727442.png

and make error as the server expected array called auction_images

0 likes
2 replies
CrastyCrap's avatar

@vincent15000 I am sorry i forget to mention that

async upsertAuction(payload,auction_id = null) {
            let url = auction_id ? import.meta.env.VITE_API_ENDPOINT+'/admin/updateAuction/' + auction_id :  import.meta.env.VITE_API_ENDPOINT+'/admin/createAuction';
            let data = new FormData;
            data.append('auction',payload);
            return axios({ 
                method: "POST",
                url: url,
                headers: {
                    'Authorization': 'Bearer '+ localStorage.getItem('token')
                },
                data: data
            })
        },

```

Please or to participate in this conversation.