Skip to main content

Vue js: fetching Data from API

in my code below i'm showing data from API for all flats in one page, but i couldn't figure out how to show the floor_number in each flat, below is my JSON body :

{
    "response": [
        {
            "floors": [
                {
                    "flats": [
                        {
                            "status": "",
                            "price": "80000",
                            "currency": "USD",
                            "end_date": "Not Set",
                            "buyer": " ",
                            "buyer_phone_number": "07701879915",
                            "receipt_number_field": "058329",
                            "size_unit": "M",
                            "_id": "61e6bccba5da17be7a90fe2e",
                            "flat_number": 1,
                            "description": "This is a newly created flat.",
                            "city": "",
                            "payment": {
                                "installment_payment": {
                                    "installments": [
                                        {
                                            "amount": "12000.00",
                                            "date": "2022-02-12",
                                            "is_paid": true
                                        },
                                        {
                                            "amount": "12000.00",
                                            "date": "2023-03-03",
                                            "is_paid": false
                                        },
                                        {
                                            "amount": "16000.00",
                                            "date": "2023-08-19",
                                            "is_paid": false
                                        },
                                        {
                                            "amount": "0.00",
                                            "date": "2022-02-20",
                                            "is_paid": false
                                        },
                                        {
                                            "amount": "342",
                                            "date": "2022-03-12",
                                            "is_paid": false
                                        }
                                    ],
                                    "remaining": "67316"
                                },
                                "paid_amount": "12684"
                            },
                            "floor": "61e6bccba5da17be7a90fe2d",
                            "building": "61e6bccba5da17be7a90fe2c",
                            "size": "176.25",
                            "directions": " ",
                            "createdAt": "2022-01-18T13:12:53.212Z",
                            "updatedAt": "2022-02-12T12:19:43.862Z",
                            "__v": 0
                        },
                        {
                            "status": "",
                            "price": "Not set",
                            "currency": "USD",
                            "end_date": "2022-02-16",
                            "buyer": "Not Set",
                            "buyer_phone_number": "Not Set",
                            "receipt_number_field": "Not Set",
                            "size_unit": "M",
                            "_id": "61e6bccba5da17be7a90fe2f",
                            "flat_number": 2,
                            "description": "This is a newly created flat.",
                            "city": "",
                            "floor": "61e6bccba5da17be7a90fe2d",
                            "building": "61e6bccba5da17be7a90fe2c",
                            "size": "176.25",
                            "directions": " ",
                            "createdAt": "2022-01-18T13:12:53.446Z",
                            "updatedAt": "2022-02-13T07:42:26.750Z",
                            "__v": 0
                        },
                        {
                            "status": "",
                            "price": "27441",
                            "currency": "USD",
                            "end_date": "2022-02-17",
                            "buyer": "new",
                            "buyer_phone_number": "7544112",
                            "receipt_number_field": "0432516",
                            "size_unit": "M",
                            "_id": "61e6bccba5da17be7a90fe30",
                            "flat_number": 3,
                            "description": "This is a newly created flat.",
                            "city": "",
                            "floor": "61e6bccba5da17be7a90fe2d",
                            "building": "61e6bccba5da17be7a90fe2c",
                            "size": "132",
                            "directions": "",
                            "createdAt": "2022-01-18T13:12:53.447Z",
                            "updatedAt": "2022-02-14T15:18:33.228Z",
                            "__v": 0
                        },
                        {
                            "status": "",
                            "price": "Not set",
                            "currency": "USD",
                            "end_date": "Not Set",
                            "buyer": "Not Set",
                            "buyer_phone_number": "Not Set",
                            "receipt_number_field": "Not Set",
                            "size_unit": "M",
                            "_id": "61e6bccba5da17be7a90fe31",
                            "flat_number": 4,
                            "description": "This is a newly created flat.",
                            "city": "",
                            "payment": null,
                            "floor": "61e6bccba5da17be7a90fe2d",
                            "building": "61e6bccba5da17be7a90fe2c",
                            "size": "184",
                            "directions": " ",
                            "createdAt": "2022-01-18T13:12:53.447Z",
                            "updatedAt": "2022-01-18T13:12:53.447Z",
                            "__v": 0
                        },
                        {
                            "status": "",
                            "price": "Not set",
                            "currency": "USD",
                            "end_date": "Not Set",
                            "buyer": "Not Set",
                            "buyer_phone_number": "Not Set",
                            "receipt_number_field": "Not Set",
                            "size_unit": "M",
                            "_id": "61e6bccba5da17be7a90fe32",
                            "flat_number": 5,
                            "description": "This is a newly created flat.",
                            "city": "",
                            "payment": null,
                            "floor": "61e6bccba5da17be7a90fe2d",
                            "building": "61e6bccba5da17be7a90fe2c",
                            "size": "184",
                            "directions": " ",
                            "createdAt": "2022-01-18T13:12:53.447Z",
                            "updatedAt": "2022-01-18T13:12:53.447Z",
                            "__v": 0
                        },
                        {
                            "status": "ava",
                            "price": "Not set",
                            "currency": "USD",
                            "end_date": "Not Set",
                            "buyer": "Not Set",
                            "buyer_phone_number": "Not Set",
                            "receipt_number_field": "Not Set",
                            "size_unit": "M",
                            "_id": "61e6bccba5da17be7a90fe33",
                            "flat_number": 6,
                            "description": "This is a newly created flat.",
                            "city": "city",
                            "payment": null,
                            "floor": "61e6bccba5da17be7a90fe2d",
                            "building": "61e6bccba5da17be7a90fe2c",
                            "size": "132",
                            "directions": "south",
                            "createdAt": "2022-01-18T13:12:53.447Z",
                            "updatedAt": "2022-02-12T17:31:21.171Z",
                            "__v": 0
                        }
                    ],
                    "_id": "61e6bccba5da17be7a90fe2d",
                    "floor_number": 1,
                    "description": "This is a newly created floor.",
                    "createdAt": "2022-01-18T13:12:53.447Z",
                    "updatedAt": "2022-01-18T13:12:53.447Z",
                    "__v": 0
                },

P.s: i have 6 flats in each floor

 <b-card-body class="px-lg-5 py-lg-5" v-for="flat in flats" :key="flat._id"> // flats API where i have all flats
                        <div class="text-center text-muted mb-4 border-dash">
                            <p class="city"></p>

                            <span v-for="(building,index) in buildings" :key="index"> //JSOn body provided above
                                <p class="iconB" v-if="building._id.includes(flat.building)"> building number </p>
  
                                     <h3> floor</h3> //not working
                            </span>

                            <h2> <i class="fas fa-user"></i> </h2>
                            <h3 class="mb-5">flat no ()</h3>

in my code above every thing is showing except the floor :\

any help?

Via Active questions tagged javascript - Stack Overflow https://ift.tt/n9Lbek7

Comments