Skip to content

Commit 5c59d35

Browse files
committed
Axios instance is working properly now.
1 parent 1d51001 commit 5c59d35

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "laravel-frontend-file-manager",
3-
"version": "3.0.34",
3+
"version": "3.0.44",
44
"description": "File manager for Laravel",
55
"keywords": [
66
"laravel",

src/FileManager.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,14 @@ export default {
131131
let settings = localstore.getStorage(localstore.axiosSettingType);
132132
133133
if(settings) {
134-
if(settings.baseURL) HTTP.defaults.baseURL = settings.baseURL;
135-
if(settings.withCredentials) HTTP.defaults.withCredentials = settings.withCredentials;
136-
if(settings.headers) HTTP.defaults.headers = settings.headers;
134+
HTTP.interceptors.request.use( async config => {
135+
config.baseURL = settings.baseURL;
136+
config.withCredentials = settings.withCredentials;
137+
config.headers = settings.headers;
138+
139+
return config;
140+
}, error => Promise.reject(error)
141+
);
137142
} else {
138143
throw `settings.baseURL: ${settings.baseURL}, settings.withCredentials: ${settings.withCredentials}, settings.headers: ${settings.headers} is set!`;
139144
}

src/http/axios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ if(settings) {
1010
}
1111

1212
// set new axios instance
13-
export default axios;
13+
export default axios.create(settings);

0 commit comments

Comments
 (0)