Changeset 5528b99 for frontend/src/axios.js
- Timestamp:
- 01/16/24 16:34:03 (9 months ago)
- Branches:
- master
- Children:
- 07f4e8b
- Parents:
- e6c2521
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/axios.js
re6c2521 r5528b99 1 1 import axios from "axios"; 2 3 2 4 3 const instance = axios.create({ 5 4 baseURL: "http://localhost:8080/", 6 5 withCredentials: true, 7 maxRedirects: 1, 8 beforeRedirect: (options, { headers }) => { 9 console.log(options) 10 if (options.hostname === "example.com") { 11 options.auth = "user:password"; 12 }} 13 6 maxRedirects: 1 14 7 }) 15 8 9 instance.interceptors.response.use(function (response) { 10 // Any status code that lie within the range of 2xx cause this function to trigger 11 // Do something with response data 12 return response; 13 }, function (error) { 14 console.log(error) 15 // window.location.href="/login" 16 // Any status codes that falls outside the range of 2xx cause this function to trigger 17 // Do something with response error 18 return Promise.reject(error); 19 }); 20 16 21 export default instance
Note:
See TracChangeset
for help on using the changeset viewer.