I'm currently building a properties website using Nuxt JS (Vue JS). I'm new to the whole API / JSON scene and am having difficulty in passing a specific json item/object to a view. Basically, I have a list of properties in the following JSON format:
{
"data": [
{
"address": "1 some street, Bridgend, Bridgend, CF36 1ER",
"price": "185000",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu laoreet ligula. Nullam urna velit, lobortis tristique vestibulum quis, congue et nunc. Nam suscipit nulla quis suscipit dictum.",
"features": ["Stone", "solid", "is fluorescent green"],
"sold": true,
"type": "detached",
"thumbnail": "http://placehold.it/400x400",
"id": 12,
"bedrooms": "Six"
},
{
"address": "10 some street, Bridgend, Bridgend, CF36 1ER",
"price": "50000",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu laoreet ligula. Nullam urna velit, lobortis tristique vestibulum quis, congue et nunc. Nam suscipit nulla quis suscipit dictum.",
"features": ["Feature 1", "Feature 3", "Feature 4"],
"sold": false,
"type": "semi-detached",
"thumbnail": "http://placehold.it/400x400",
"id": 13,
"bedrooms": "4"
}
}
I am able to successfully show this data on a main property listing view. I have also successfully managed to get it so that it generates a different view based on the "id" number (e.g: 'mysite.com/property/12'), the main property listing view contains a v-for which loops over, and my link to the property is as follows:
This part works fine. The main problem is on the generated view it obviously doesn't have a json file for each property so the following code is unable to find the individual property data:
I'm essentially just trying to pull out the property data for each property, e.g: (property ID: 12) and display that on the view, obviously it would update depending on the json data. How could I modify this, do I need to change:
The problem is, I'm trying not to overcomplicate the data as it would essentially be coming from an API once complete, I'm just generating fake/dummy data for now.
Many thanks, if someone could provide a code example or point me in the right direction. Thanks!
I'm currently building a properties website using Nuxt JS (Vue JS). I'm new to the whole API / JSON scene and am having difficulty in passing a specific json item/object to a view. Basically, I have a list of properties in the following JSON format:
I am able to successfully show this data on a main property listing view. I have also successfully managed to get it so that it generates a different view based on the
"id"
number (e.g: 'mysite.com/property/12'), the main property listing view contains av-for
which loops over, and my link to the property is as follows:This part works fine. The main problem is on the generated view it obviously doesn't have a json file for each property so the following code is unable to find the individual property data:
I'm essentially just trying to pull out the property data for each property, e.g: (property ID: 12) and display that on the view, obviously it would update depending on the json data. How could I modify this, do I need to change:
To something like:
Or, could I change:
To:
The problem is, I'm trying not to overcomplicate the data as it would essentially be coming from an API once complete, I'm just generating fake/dummy data for now.
Many thanks, if someone could provide a code example or point me in the right direction. Thanks!
UPDATE:
Could I maybe do something like this:
or: