This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
/* The code `axios.interceptors.request.use((config) => { ... })` is creating an interceptor for Axios | |
requests. */ | |
axios.interceptors.request.use((config) => { | |
// Log to print that request is intiated.. | |
console.log('Request was sent'); | |
// Data that can be keep track of which are sent in request | |
console.log(`[${config.method}] ${config.url}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Axios response interceptor setup | |
axios.interceptors.response.use( | |
(response) => { | |
// Handle successful responses | |
console.log('Response received:', response.data); | |
return response; | |
}, | |
(error) => { | |
// Handle response errors | |
console.error('Error encountered:', error); |