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

Popular posts from this blog

Prop `className` did not match in next js app

I have written a sample code ( Github Link here ). this is a simple next js app, but giving me error when I refresh the page. This seems to be the common problem and I tried the fix provided in the internet but does not seem to fix my issue. The error is Warning: Prop className did not match. Server: "MuiBox-root MuiBox-root-1" Client: "MuiBox-root MuiBox-root-2". Did changes for _document.js, modified _app.js as mentioned in official website and solutions in stackoverflow. but nothing seems to work. Could someone take a look and help me whats wrong with the code? Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

How to show number of registered users in Laravel based on usertype?

i'm trying to display data from the database in the admin dashboard i used this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count(); echo $users; ?> and i have successfully get the correct data from the database but what if i want to display a specific data for example in this user table there is "usertype" that specify if the user is normal user or admin i want to user the same code above but to display a specific usertype i tried this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count()->WHERE usertype =admin; echo $users; ?> but it didn't work, what am i doing wrong? source https://stackoverflow.com/questions/68199726/how-to-show-number-of-registered-users-in-laravel-based-on-usertype

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console