Last active
September 6, 2020 15:50
-
-
Save wilcorrea/211333dc5fe123dcf2ec9b887e652290 to your computer and use it in GitHub Desktop.
This file contains 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> | |
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Não seria response.rows ?
if (Array.isArray(respons.rows)) { this.rows = respons.rows return }