Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Can I use reactotron-apisauce with Axios


Can I use reactotron-apisauce with Axios


Yes, you can use reactotron-apisauce with Axios. Here's how you can set it up:

1. Install the required packages:


npm install reactotron-react-native reactotron-apisauce apisauce

2. In your Reactotron configuration file (e.g., `ReactotronConfig.js`), import and configure the `reactotron-apisauce` plugin:

javascript
import Reactotron from 'reactotron-react-native'
import apisaucePlugin from 'reactotron-apisauce'

Reactotron
  .configure()
  .useReactNative()
  .use(apisaucePlugin())
  .connect()

3. In your Axios setup file (e.g., `api.js`), create your Axios instance and add the Reactotron monitor:

javascript
import { create } from 'apisauce'
import Reactotron from 'reactotron-react-native'

const api = create({
  baseURL: 'https://your-api.com/api/v1',
  headers: {
    'Content-Type': 'application/json',
  },
})

api.addMonitor(Reactotron.apisauce)

export default api

Now, whenever you make an Axios request using the `api` instance, Reactotron will display the request and response details in the Reactotron console.

The key steps are:

1. Install the required packages.
2. Configure the `reactotron-apisauce` plugin in your Reactotron setup.
3. Create your Axios instance using `apisauce` and add the Reactotron monitor to it.

By following these steps, you can effectively use Reactotron to monitor your Axios requests and responses in your React Native application.[1][2][3]

Citations:
[1] https://stackoverflow.com/questions/49269595/how-to-set-up-reactotron-apisauce-in-react-native
[2] https://github.com/infinitered/reactotron-apisauce
[3] https://docs.infinite.red/reactotron/plugins/apisauce/
[4] https://github.com/infinitered/reactotron/issues/520
[5] https://www.npmjs.com/package/apisauce?activeTab=dependents