Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 56 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | // The Vue build version to load with the `import` command |
||
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({ |
||
|
|||
54 | el: '#app', |
||
55 | router, |
||
56 | components: { App }, |
||
57 | template: '<App/>' |
||
58 | }) |
||
59 |