Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 1.34 KB

plugin-apisauce.md

File metadata and controls

46 lines (31 loc) · 1.34 KB

reactotron-apisauce

Apisauce is a lightweight wrapper around the fantastic Axios networking library.

API Response

Installing

npm i --save-dev reactotron-apisauce

Configuring

In the place where you setup your reactotron configuration, you import reactotron-apisauce plugin and throw it at Reactotron.

import apisaucePlugin from 'reactotron-apisauce'  // <--- import

// then plug it in when you configure Reactotron.

Reactotron
  .configure()
  .use(apisaucePlugin({
    // ignoreContentTypes: /^(image)\/.*$/i   // <--- a way to skip printing the body of some requests (default is any image)
  })) // <-- here we go!!!
  .connect()

Next, wherever you create your api for you application, bring in Reactotron and attach the monitor to your apisauce instance.

import Reactotron from 'reactotron-react-js'
// import Reactotron from 'reactotron-react-native' // or use this for mobile

// Apisauce has a feature where you can attach a handler to watch
// all requests/response flowing through your api.  You can hook this up:
api.addMonitor(Reactotron.apisauce)

// or ...

// if you just wanted to track on 500's
api.addMonitor(response => {
  if (response.problem === 'SERVER_ERROR')
    Reactotron.apisauce(response)
})