Skip to content

Instantly share code, notes, and snippets.

@juhahinkula
Created June 20, 2019 11:26
Show Gist options
  • Select an option

  • Save juhahinkula/adbad1a530ad6450c89ac82d9669fc50 to your computer and use it in GitHub Desktop.

Select an option

Save juhahinkula/adbad1a530ad6450c89ac82d9669fc50 to your computer and use it in GitHub Desktop.
<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