Source: paulund.co.uk

Log Axios Requests
When working with APIs in your Javascript application it can be useful to be able to debug the requests and responses you're using to interact with the API. Axios comes with a feature called https://axios-http.com/docs/interceptors that allow you to run some code before a request and after a response. This is a good place to add some code that runs on every request, you can put your debug messages in here. axios.interceptors.request.use(request => { console.log('Starting Request', JSON.stringify(request, null, 2)) return request})axios.interceptors.response.use(response => { console.log('Response:', JSON.stringify(response, null, 2)) return response}) Now when you use axios to make requests to apis you'll get debug messages for each request and response.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners