Inforage
Inforage

Reputation: 79

How to push the object into the first array?

How can I push the Image object into the first array?

//Vue (my current code)
productList.value.push(res.data.returnData.info);
var a ='Image';
var obj={};
obj[a] = res.data.returnData.image[0].ppName;
productList.value.push(obj);

enter image description here

Upvotes: 1

Views: 74

Answers (1)

Rohìt Jíndal
Rohìt Jíndal

Reputation: 27192

As per the screenshot shared by you, I can see it's an array of objects. So you want to merge image object properties into first object ? If Yes, Here you go :

const imageObj = {
  image: 'Image URL'
};

productList.value[0] = Object.assign(productList.value[0], imageObj);

Upvotes: 1

Related Questions