Closed primodeckers closed 5 years ago
@primodeckers hi, thanks for sending me this issue. I think the issue occurs because data
is not defined inside data. Also, you store the response from the API at the this.notas
object instead this.data
. It would be nice to use loading and error flags in order to check the API response, put loading/change visibility of the component while loading... So, I would propose to replace the template as below:
<vue-json-to-csv
v-if="!loading && !error"
:jsonData="notas"
:labels="{
id: { title: 'id' },
co_tipo_nota: { title: 'co_tipo_nota' },
ds_nota: { title: 'ds_nota' },
ds_outro_criterio: { title: 'ds_outro_criterio' },
ds_nofl_avaliacao_anonimata: { title: 'fl_avaliacao_anonima' },
dt_nota: { title: 'dt_nota' },
}"
@success="val => handleSuccess(val)"
@error="val => handleError(val)">
<button>
<b>My custom button</b>
</button>
</vue-json-to-csv>
data object:
data: function() {
return {
nota: {},
notas: []
loading: false,
error: false
}
},
and the call:
this.loading = true
const url = `${baseApiUrl}/notas`
axios.get(url).then(res => {
this.notas = res.data
this.error = false
this.loading = false
}).catch(error => {
this.notas = []
this.error = true
this.loading = false
console.log(error)
})
I think it should be a nice idea to add an async feature at the module, I will have a look and create a new ticket for this.
Thanks! Please let me know if that works for you!
I want to receive an array that I received through the axios, but this one giving error. can you help me.
I'm trying to bind to the component,
<vue-json-to-csv: jsonData = "data">
but this one giving error telling me that it is not an array my code:
the error that occurs:
[Vue warn]: Property or method "data" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
found in
---> at src/components/home/DowloadCvsThree.vue