Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Change vue-resource to axios
Browse files Browse the repository at this point in the history
vue-resource has some issue on handling json data without http header.
See #16, but it doesn't related syntex error handling.
  • Loading branch information
rishubil committed Sep 6, 2017
1 parent d95c107 commit 0df2a67
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 153 deletions.
2 changes: 1 addition & 1 deletion source/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"lint": "eslint --ext .js,.vue src"
},
"dependencies": {
"axios": "^0.16.2",
"clipboard": "^1.7.1",
"hangul-js": "^0.2.4",
"lodash": "^4.17.4",
"spectre.css": "^0.2.14",
"vue": "^2.3.3",
"vue-lazyload": "^1.0.6",
"vue-resource": "^1.3.4",
"vue-router": "^2.6.0",
"vue2-animate": "^1.0.4"
},
Expand Down
57 changes: 31 additions & 26 deletions source/src/components/chat/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<script>
import _ from 'lodash';
import axios from 'axios';
const TWITCH_EMOTE_URL_TEMPLATE = 'https://static-cdn.jtvnw.net/emoticons/v1/{image_id}/3.0';
Expand Down Expand Up @@ -106,37 +107,41 @@
if (url === '') {
url = 'https://rishubil.github.io/jsassist-open-dccon/static/dccon_list.json';
}
// eslint-disable-next-line
addChatMessage('system', 'SYSTEM', '디시콘 목록을 불러오는 중..');
t.$http.get(url, {responseType: 'json'}).then((response) => {
try {
t.dccons = _(response.body.dccons)
.flatMap(v => _(v.keywords).map(o => [o, v]).value())
.fromPairs()
.value();
t.dcconKeywords = _(t.dccons)
.keys()
.sortBy()
.reverse()
.value();
// eslint-disable-next-line
addChatMessage('system', 'SYSTEM', '디시콘 목록 불러오기 완료.');
} catch (e) {
axios.get(url)
.then((response) => {
try {
t.dccons = _(response.data.dccons)
.flatMap(v => _(v.keywords).map(o => [o, v]).value())
.fromPairs()
.value();
t.dcconKeywords = _(t.dccons)
.keys()
.sortBy()
.reverse()
.value();
// eslint-disable-next-line
addChatMessage('system', 'SYSTEM', '디시콘 목록 불러오기 완료.');
} catch (e) {
// eslint-disable-next-line
addChatMessage('system', 'SYSTEM', '디시콘 목록을 불러올 수 없습니다.');
// eslint-disable-next-line no-console
console.log(e);
// eslint-disable-next-line no-console
console.log(response);
}
cb();
})
.catch((error) => {
// eslint-disable-next-line
addChatMessage('system', 'SYSTEM', '디시콘 목록을 불러올 수 없습니다.');
// eslint-disable-next-line no-console
console.log(e);
// eslint-disable-next-line no-console
console.log(response);
}
cb();
}, (response) => {
// eslint-disable-next-line
addChatMessage('system', 'SYSTEM', '디시콘 목록을 불러올 수 없습니다.');
// eslint-disable-next-line no-console
console.log(response);
cb();
});
console.log(error);
cb();
});
}, 100);
},
loadTwitchEmotes() {
Expand Down
31 changes: 18 additions & 13 deletions source/src/components/list/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

<script>
import _ from 'lodash';
import axios from 'axios';
import Clipboard from 'clipboard';
import Bus from '@/bus';
import Search from './ui/Search';
Expand Down Expand Up @@ -65,21 +66,25 @@
if (url === '') {
url = 'https://rishubil.github.io/jsassist-open-dccon/static/dccon_list.json';
}
this.$http.get(url).then((response) => {
try {
this.dcconList = response.body.dccons;
} catch (e) {
axios.get(url)
.then((response) => {
try {
this.dcconList = response.data.dccons;
} catch (e) {
Bus.$emit('TOAST_MSG', '디시콘 목록을 불러올 수 없습니다.');
// eslint-disable-next-line no-console
console.log(e);
// eslint-disable-next-line no-console
console.log(response);
}
})
.catch((error) => {
Bus.$emit('TOAST_MSG', '디시콘 목록을 불러올 수 없습니다.');
// eslint-disable-next-line no-console
console.log(e);
// eslint-disable-next-line no-console
console.log(response);
}
}, (response) => {
Bus.$emit('TOAST_MSG', '디시콘 목록을 불러올 수 없습니다.');
// eslint-disable-next-line no-console
console.log(response);
});
console.log(error);
});
// eslint-disable-next-line no-unused-vars
const clipboard = new Clipboard('.clipboard');
},
Expand Down
2 changes: 0 additions & 2 deletions source/src/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import Vue from 'vue';
import VueResource from 'vue-resource';
import VueLazyload from 'vue-lazyload';
import App from './App';
import router from './router';

Vue.use(VueLazyload);
Vue.use(VueResource);
Vue.config.productionTip = false;

/* eslint-disable no-new */
Expand Down
Loading

0 comments on commit 0df2a67

Please sign in to comment.