Yoshie Muranaka | 74c24f1 | 2019-12-03 10:45:46 -0800 | [diff] [blame^] | 1 | import Axios from "axios"; |
| 2 | |
| 3 | const api = Axios.create(); |
| 4 | |
| 5 | // TODO: this is a temporary workaround until |
| 6 | // authentication with login is working |
| 7 | const username = process.env.VUE_APP_USERNAME; |
| 8 | const password = process.env.VUE_APP_PASSWORD; |
| 9 | if (username && password) { |
| 10 | api.defaults.auth = {}; |
| 11 | api.defaults.auth.username = username; |
| 12 | api.defaults.auth.password = password; |
| 13 | } |
| 14 | |
| 15 | export default { |
| 16 | get(path) { |
| 17 | return api.get(path); |
| 18 | }, |
| 19 | delete(path, payload) { |
| 20 | return api.delete(path, payload); |
| 21 | }, |
| 22 | post(path, payload) { |
| 23 | return api.post(path, payload); |
| 24 | }, |
| 25 | patch(path, payload) { |
| 26 | return api.patch(path, payload); |
| 27 | }, |
| 28 | put(path, payload) { |
| 29 | return api.put(path, payload); |
| 30 | }, |
| 31 | all(promises) { |
| 32 | return Axios.all(promises); |
| 33 | } |
| 34 | }; |