'How enable console log in VUE-CLI during development
I have been trying to figure out how to console.log('whatever') during learning some VueJs development in my methods in order to understand some behaviour of whatever I am doing here.
I understand that there're some questions already asked here and have scoped into ESLINT documentation to try an figure this out... I just can't actually understand what I should do.
My code:
methods: {
submitData() {
this.$http.post('https://vue-testing-8a2de.firebaseio.com/data.json', this.user)
.then(response => {
console.log(response);
}, error => {
console.log(error)
})
}
}
This is the error on ESLINT:
Failed to compile.
./src/App.vue
Module Error (from ./node_modules/eslint-loader/index.js):
error: Unexpected console statement (no-console) at src/App.vue:35:22:
33 | this.$http.post('https://vue-testing-8a2de.firebaseio.com/data.json',this.user)
34 | .then(response => {
> 35 | console.log(response);
| ^
36 | }, error => {
37 | console.log(error)
38 | })
error: Unexpected console statement (no-console) at src/App.vue:37:22:
35 | console.log(response);
36 | }, error => {
> 37 | console.log(error)
| ^
38 | })
39 | }
40 | }
2 errors found.
I have looked into this website:
I tried commenting the previous line before console.log:
/*eslint no-console: "error"*/(but it doesn't works well)
I need a step by step guide if I need to mess with JSON rules, as I have never done this before.
I am using vue-cli on WebStorm.
Thanks in advance!
Solution 1:[1]
1 Edit package.json
2 Then find "rules": {}
3 Change to this "rules":{"no-console":0}
4 if you Vue server in on, off it and run it again. Then the issue will be done
Solution 2:[2]
Just use console.table(value) or console.info(value) instead of console.log(value)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ardalan Farkhondeh |
| Solution 2 | p12s |
