diff options
author | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2019-12-03 21:45:46 +0300 |
---|---|---|
committer | Derick Montague <derick.montague@ibm.com> | 2020-01-22 07:45:02 +0300 |
commit | 74c24f15b8f7d97ffaad657c25a35eb2081e739e (patch) | |
tree | aa6d0980785c8931910951a6ce1fa821cc6e2395 /src/store/api.js | |
parent | 97d86b33d78c3b92b29915d6afba125b67bc6714 (diff) | |
download | webui-vue-74c24f15b8f7d97ffaad657c25a35eb2081e739e.tar.xz |
Add proxy dev server for local development
Adding proxy server to vue config to handle API requests
for local development. You need to create a .env.development.local file with
BASE_URL, VUE_APP_USERNAME, VUE_APP_PASSWORD defined.
Temporarily adding authentication to defaults until
login flow is functional.
Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Signed-off-by: Derick Montague <derick.montague@ibm.com>
Change-Id: Ib1a1a992508fb9567af66ecb5775638e6ae6ee8d
Diffstat (limited to 'src/store/api.js')
-rw-r--r-- | src/store/api.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/store/api.js b/src/store/api.js new file mode 100644 index 00000000..d40ad0ad --- /dev/null +++ b/src/store/api.js @@ -0,0 +1,34 @@ +import Axios from "axios"; + +const api = Axios.create(); + +// TODO: this is a temporary workaround until +// authentication with login is working +const username = process.env.VUE_APP_USERNAME; +const password = process.env.VUE_APP_PASSWORD; +if (username && password) { + api.defaults.auth = {}; + api.defaults.auth.username = username; + api.defaults.auth.password = password; +} + +export default { + get(path) { + return api.get(path); + }, + delete(path, payload) { + return api.delete(path, payload); + }, + post(path, payload) { + return api.post(path, payload); + }, + patch(path, payload) { + return api.patch(path, payload); + }, + put(path, payload) { + return api.put(path, payload); + }, + all(promises) { + return Axios.all(promises); + } +}; |