I have a list I want to update with data from an API call - done this many times and works OK, but I must be doing something different with this solution is the list is not updating when data is returned from the API call:
<template>
Set list: {{setList}}
<div v-for="(set, index) in setList">
{{ set.title }}
// index is used in the loop...
</div>
</template>
<script>
import queries from '../api/queries'
export default {
data: () => ({
setList: []
}),
created() {
this.setList = queries.getSetList();
},
....
</script>
queries.js
async getSetList () {
let setList=[];
await API.graphql({
setList=get the data
}).then((response) => {
return(setList)
})
}
The print statement: Set List: [object Promise] and the list is not printed in the for loop.
The promise does return with data (showing in the dev console).
I had a similar query resolved by @IVOGELOV (thank you!) here and looking for a non vuex solution.
Thanks