2

i want to retrieve some array inside an array but i dont know how, please read my explanation first

here is my json response

{
"Value": [
    {
        "id": "5ff97d740e788778dd66ee25",
        "id_order": "ORD-434183",
        "nama_pelanggan": "Herman",
        "total": 80000.0,
        "jumlah_item": 4.0,
        "cart": [
            {
                "id_cart": "CART-112010",
                "nama_produk": "Ayam Bakar",
                "jumlah": 4.0,
                "harga": 20000.0,
                "subtotal": 80000.0,
                "notes": "ga ada"
            }
        ],
        "admin_no": "ADM-431525",
        "admin_name": "Admin",
        "created_at": "2021-01-09 16:55:00",
        "updated_at": "2021-01-09 16:55:00"
    }
],
"Status": true,
"Messages": [
    {
        "Type": 200,
        "Title": "TotalRows",
        "Message": "1"
    }
]}

as you can see the value of "value" is an array and in that array also have an array "cart"

i want to retrieve this array "cart" and put it in a table

here is how i retrieve the response using vue js Mapping an Array to Elements with v-for

var vm = new Vue({
el: '#app',
data: {
    list: {
        items: [],
    },
}

            var formData = new FormData();
            formData.append('filterparams', JSON.stringify(filters));
            formData.append('display', JSON.stringify(_self.list.config.display));
            formData.append('auth', sessionStorage.getItem("token"));

            _self.$http.post(hostapi + 'order/GetByParamsHistory', formData, {
                headers: {
                    'Content-Type': 'multipart/form-data'
                }
            });
            var obj = response.data;
            _self.list.items = obj.Value; // the value from array "Value"

here is the table html code

enter image description here

and now I don't know how to insert an existing array in the array into the html table

1 Answer 1

1

You can access the array on the basis of the array index.

Suppose, if list contains the json response's value field then you can access it like. list['0'].cart.

Sign up to request clarification or add additional context in comments.

11 Comments

thanks to you i can retrieve the array, but the contents of the cart array do not match the contents, like only taking from the first array, can you help me to solve this ?
all of my data order now have the same cart item in the front end, what should i do to solve this ???
With v-for we should also pass a key something like this: <tr v-for="(row, index) in list['0'].cart" :key="index>.
what is index ?
do you know how to implement increment in this code list['0'].cart ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.