File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -2,12 +2,30 @@ import axios from 'axios';
22
33const config = useRuntimeConfig ( )
44
5+ console . log ( `[axios] Backend URL: ${ config . BACKEND_URL } ` )
6+
57const axiosInstance = axios . create ( {
6- baseURL : config . BACKEND_URL , // Base URL for your API
8+ baseURL : config . BACKEND_URL ,
79 headers : {
810 'Content-Type' : 'application/json' ,
911 'token' : config . BACKEND_TOKEN ,
1012 } ,
1113} ) ;
1214
15+ axiosInstance . interceptors . request . use ( ( req ) => {
16+ console . log ( `[axios] → ${ req . method ?. toUpperCase ( ) } ${ req . baseURL } ${ req . url } ` )
17+ return req
18+ } )
19+
20+ axiosInstance . interceptors . response . use (
21+ ( res ) => {
22+ console . log ( `[axios] ← ${ res . status } ${ res . config . url } ` )
23+ return res
24+ } ,
25+ ( err ) => {
26+ console . error ( `[axios] ✗ ${ err . config ?. url } — ${ err . message } ` )
27+ return Promise . reject ( err )
28+ }
29+ )
30+
1331export default axiosInstance ;
You can’t perform that action at this time.
0 commit comments