Created
June 20, 2019 11:26
-
-
Save juhahinkula/adbad1a530ad6450c89ac82d9669fc50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <div> | |
| <h1>CarList</h1> | |
| <table> | |
| <tbody> | |
| <tr v-for="(car, index) in cars" v-bind:key="index"> | |
| <td>{{car.brand}}</td> | |
| <td>{{car.model}}</td> | |
| <td>{{car.color}}</td> | |
| <td>{{car.year}}</td> | |
| <td>{{car.price}} €</td> | |
| <td>{{car.fuel}}</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| </template> | |
| <script> | |
| import axios from 'axios'; | |
| export default { | |
| name: 'CarList', | |
| data() { | |
| return { | |
| cars: [], | |
| } | |
| }, | |
| mounted() { | |
| axios | |
| .get('https://carstockrest.herokuapp.com/cars') | |
| .then(response => (this.cars = response.data._embedded.cars)) | |
| } | |
| } | |
| </script> | |
| <style> | |
| table { | |
| margin-left:auto; | |
| margin-right:auto; | |
| } | |
| </style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment