728x90
반응형
SMALL
- 설치
yarn add axios
or
npm install axios --save
- main.js
import axios from 'axios'
Vue.prototype.$http = axios
- 사용법
- get 방식
1 2 3 4 5 6 7 8 |
this.$http .get('api_url', { params: { name: 'TEST' } }) .then(res => { console.log(res); }) .catch(error => { console.log(error); }); |
- post 방식
1 2 3 4 5 6 7 8 9 10 11 12 13 |
let formData = new FormData(); formData.append('email', this.email);
this.$http .post('api_url', formData) .then(res => { console.log(res); }) .catch(error => { console.log(error); }); |
728x90
반응형
LIST
'Program > Vue' 카테고리의 다른 글
Vue-cli 3에서 eslint 설정 (0) | 2018.08.01 |
---|---|
vue build 시 쌍따옴표가 삭제되서 에러 날 때(vue.config.js) (0) | 2018.08.01 |
Vue Cli 설치 (0) | 2018.08.01 |
Window 패키지 관리 Chocolatey (0) | 2018.08.01 |
Mac Homebrew 설치 (0) | 2018.08.01 |