Completed
Branch vue-dev (285fcd)
by Seth
41s
created

src/main.js   A

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 56
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
c 2
b 0
f 0
nc 1
dl 0
loc 56
rs 10
wmc 3
mnd 0
bc 3
fnc 3
bpm 1
cpm 1
noi 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A main.js ➔ ??? 0 14 1
1
// The Vue build version to load with the `import` command
2
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3
import Vue from 'vue'
4
import App from './App'
5
import router from './router'
6
7
// element-ui
8
import Element from 'element-ui'
9
import 'element-ui/lib/theme-chalk/index.css'
10
11
// axios
12
import axios from 'axios'
13
14
// vue-moment
15
import VueMoment from 'vue-moment'
16
17
// add element-ui to vue
18
Vue.use(Element)
19
20
// add vue-moment to vue
21
Vue.use(VueMoment)
22
23
// add axios to the Vue object
24
Object.defineProperty(Vue.prototype, '$axios', { value: axios })
25
26
// create API with baseURL
27
const api = axios.create({
28
  baseURL: process.env.API_URL
29
})
30
31
// create API method to get around CORS
32
api.access = (url) => {
33
  return new Promise((resolve, reject) => {
34
    // add baseURL to given url
35
    url = api.defaults.baseURL + url
36
37
    // get yahoo's yql API with url
38
    api.get('https://query.yahooapis.com/v1/public/yql?q=SELECT * FROM json WHERE url="' + url + '"&format=json')
39
      .then((response) => {
40
        response.data = response.data.query.results.json
41
        resolve(response)
42
      })
43
      .then(reject)
44
  })
45
}
46
47
// add api to the Vue object
48
Object.defineProperty(Vue.prototype, '$api', { value: api })
49
50
Vue.config.productionTip = false
51
52
/* eslint-disable no-new */
53
new Vue({
0 ignored issues
show
Unused Code Best Practice introduced by
The object created with new Vue({IdentifierNode(...ngLiteralNode(<App/>)}) is not used but discarded. Consider invoking another function instead of a constructor if you are doing this purely for side effects.
Loading history...
54
  el: '#app',
55
  router,
56
  components: { App },
57
  template: '<App/>'
58
})
59