Unexpected token in then block

unknown

I have a following code. Why I get error unexpected token in line with for loop?

methods: {
        getStatistics() {
          let id = this.$route.params.id;
          this.$axios
            .get(id+'/', {
              params: {
               'user_pk': id,
               'start_date': this.start_date,
               'end_date': this.end_date
              }
            })
            .then(response => (
              console.log(response.data),
              this.stat_data = response.data,
              this.chartdata.datasets.data[0] = [],
              this.chartdata.datasets.data[1] = [],
              this.chartdata.labels = [],
              for (click of response.data.results) {
                this.chartdata.datasets.data[0].push(click),
                this.chartdata.datasets.data[1].push(page_views),
                this.chartdata.push(date),
                console.log(this.chartdata);
              };
            ));
        }
    }
N'Bayramberdiyev

Your code has several syntax errors. Replace , with ; at the end of each line. And ; is unnecessary at the end of for loop.

Your arrow function (then() callback) is also incorrect. It should be between brackets, not parenthesis.

Please try this:

methods: {
    getStatistics() {
        let id = this.$route.params.id;
        this.$axios.get(id+'/', {
            params: {
                'user_pk': id,
                'start_date': this.start_date,
                'end_date': this.end_date
            }
        }).then(response => {
            console.log(response.data);
            this.stat_data = response.data;
            this.chartdata.datasets.data[0] = [];
            this.chartdata.datasets.data[1] = [];
            this.chartdata.labels = [];
            for (click of response.data.results) {
                this.chartdata.datasets.data[0].push(click);
                this.chartdata.datasets.data[1].push(page_views);
                this.chartdata.push(date);
                console.log(this.chartdata);
            }
        });
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related