examples/classic/commits/app.js JAVASCRIPT 47 lines View on github.com → Search inside
1var apiURL = 'https://api.github.com/repos/vuejs/vue/commits?per_page=3&sha='23/**4 * Actual demo5 */67new Vue({8  el: '#demo',910  data: {11    branches: ['main', 'dev'],12    currentBranch: 'main',13    commits: null14  },1516  created: function () {17    this.fetchData()18  },1920  watch: {21    currentBranch: 'fetchData'22  },2324  filters: {25    truncate: function (v) {26      var newline = v.indexOf('\n')27      return newline > 0 ? v.slice(0, newline) : v28    },29    formatDate: function (v) {30      return v.replace(/T|Z/g, ' ')31    }32  },3334  methods: {35    fetchData: function () {36      var self = this37      var xhr = new XMLHttpRequest()38      xhr.open('GET', apiURL + self.currentBranch)39      xhr.onload = function () {40        self.commits = JSON.parse(xhr.responseText)41        console.log(self.commits[0].html_url)42      }43      xhr.send()44    }45  }46})

Code quality findings 5

Use let or const to avoid scope issues and hoisting
info correctness var-declaration
var apiURL = 'https://api.github.com/repos/vuejs/vue/commits?per_page=3&sha='
Use let or const to avoid scope issues and hoisting
info correctness var-declaration
var newline = v.indexOf('\n')
Use let or const to avoid scope issues and hoisting
info correctness var-declaration
var self = this
Use let or const to avoid scope issues and hoisting
info correctness var-declaration
var xhr = new XMLHttpRequest()
Remove debugging statements or use a logging library
info correctness console-log
console.log(self.commits[0].html_url)

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.