axios
https://gyazo.com/fd559c8584e1c8f3ce36ded23c1d47af
Promise based HTTP client for the browser and node.js
ブラウザや node.js で動く Promise ベースのHTTPクライアント
Features
Make XMLHttpRequests from the browser
Make http requests from node.js
Supports the Promise API
Intercept request and response
Transform request and response data
Cancel requests
Automatic transforms for JSON data
Client side support for protecting against XSRF
code:api/axios.js
// userのAPI系Service
import axios from 'axios';
import authHeader from './auth-header';
axios.defaults.baseURL = process.env.VUE_APP_API_URL_BASE;
class UserService {
getAdminBoard() {
return axios.get('admin', { headers: authHeader() });
}
}
export default new UserService();
interceptors
TODO
代替
サイズ小さくしたい時に使う
参考