I am quite new to vue.js, and I am trying to build an basic application that displays data fetched from an API.
I do not understand why I cannot use console.log inside my scripts :
<script>
import Header from './components/layout/Header.vue'
import Todos from './components/Todo.vue'
export default {
name: 'app',
components: {
Todos,
Header,
},
data () {
return {
todos : []
}
},
methods : {
created () {
fetch('https://jsonplaceholder.typicode.com/todos')
.then( resp => resp.json())
.then( data => {
console.log(data);
})
.catch(err => err)
}
}
}
</script>
I always got "unexpected console statement"
Does anybody knows how I can console log stuff inside vue scripts ? Am I missing something ??
Thanks a lot !!
You can try
methods: {
log(msg){
console.log(msg);
}
}
And when you want to write things to console, use:
{{ log(message) }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With