| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  | axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; | 
					
						
							|  |  |  | axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | axios.interceptors.request.use( | 
					
						
							| 
									
										
										
										
											2023-05-08 13:34:12 +00:00
										 |  |  |     (config) => { | 
					
						
							| 
									
										
										
										
											2023-05-05 18:21:39 +00:00
										 |  |  |         if (config.data instanceof FormData) { | 
					
						
							|  |  |  |             config.headers['Content-Type'] = 'multipart/form-data'; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             config.data = Qs.stringify(config.data, { | 
					
						
							|  |  |  |                 arrayFormat: 'repeat', | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |         return config; | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2023-05-08 13:34:12 +00:00
										 |  |  |     (error) => Promise.reject(error), | 
					
						
							| 
									
										
										
										
											2023-05-05 18:21:39 +00:00
										 |  |  | ); | 
					
						
							| 
									
										
										
										
											2024-03-10 21:31:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | axios.interceptors.response.use( | 
					
						
							|  |  |  |     (response) => response, | 
					
						
							|  |  |  |     (error) => { | 
					
						
							|  |  |  |         if (error.response) { | 
					
						
							|  |  |  |             const statusCode = error.response.status; | 
					
						
							|  |  |  |             // Check the status code
 | 
					
						
							|  |  |  |             if (statusCode === 401) { // Unauthorized
 | 
					
						
							|  |  |  |                 return window.location.reload(); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return Promise.reject(error); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | ); |