Skip to content

Instantly share code, notes, and snippets.

@wilcorrea
Last active September 6, 2020 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilcorrea/211333dc5fe123dcf2ec9b887e652290 to your computer and use it in GitHub Desktop.
Save wilcorrea/211333dc5fe123dcf2ec9b887e652290 to your computer and use it in GitHub Desktop.
<template>
<table>
<tr>
<th>Name</th>
<th>Price</th>
</tr>
<tr
v-for="(row, key) in rows"
:key="row['id']"
>
<td>{{ row['name'] }}</td>
<td>{{ row['price'] | money }}</td>
</tr>
</table>
</template>
<script>
import { money } from 'src/support/formatter'
import CarService from 'src/domains/Car/CarService'
const service = CarService.build()
export default {
name: 'CarTable',
data: () => ({
rows: []
}),
filters: {
money: money
},
methods: {
fetchRecords () {
service
.search({})
.then(this.fetchRecodsSuccess)
},
fetchRecodsSuccess (response) {
if (Array.isArray(response.rows)) {
this.rows = respons.rows
return
}
this.rows = []
}
},
mounted () {
this.fetchRecords()
}
}
</script>
@marciowelter
Copy link

Não seria response.rows ?
if (Array.isArray(respons.rows)) { this.rows = respons.rows return }

@wilcorrea
Copy link
Author

Obrigado, isso mesmo
👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment