Changeset ac19a0c for frontend/src/axios.js
- Timestamp:
- 01/13/24 23:19:50 (9 months ago)
- Branches:
- master
- Children:
- e85a562
- Parents:
- e9b4ba9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/axios.js
re9b4ba9 rac19a0c 1 1 import axios from "axios"; 2 2 3 3 4 const instance = axios.create({ 4 5 baseURL: "http://localhost:8080/", 5 6 withCredentials: true, 6 maxRedirects: 1 7 maxRedirects: 1, 8 beforeRedirect: (options, { headers }) => { 9 console.log(options) 10 if (options.hostname === "example.com") { 11 options.auth = "user:password"; 12 }} 13 7 14 }) 8 15 9 instance.interceptors.response.use(function (response) {10 // Any status code that lie within the range of 2xx cause this function to trigger11 // Do something with response data12 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 trigger17 // Do something with response error18 return Promise.reject(error);19 });20 21 16 export default instance
Note:
See TracChangeset
for help on using the changeset viewer.