Could someone take a look at this snippet of code and help me figure out why I'm encountering this error?
Error: json is undefined
(referring to the test: json below).
I've made sure to define it, point it to the correct component, and the json data is successfully fetched (I can see the complete object in the console). So why is my component not able to display it? Appreciate any assistance from users familiar with Vue.js.
The content of the .vue file:
<template>
<div id="app">
{{ test }}
</div>
</template>
<script>
export default {
name: 'app',
data () {
return {
test: json
}
}
}
</script>
The content of the .js file:
new Vue({
el: '#app',
data: () => ({
json: {}
}),
created: function () {
apigClient.invokeApi(apiPathParams, apiPathTemplate, apiMethod, apiAdditionalParams, apiBody).then((response) => {
this.json = response
console.log(this.json)
})
router,
template: '<app/>',
components: { App }
})