-
Notifications
You must be signed in to change notification settings - Fork 936
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds reactotron-apisauce documentation. (#156)
- Loading branch information
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# reactotron-apisauce | ||
|
||
[Apisauce](http://github.com/skellock/apisauce) is a lightweight wrapper around the fantastic [Axios](https://github.com/mzabriskie/axios) networking library. | ||
|
||
![API Response](./images/apisauce/apisauce.jpg) | ||
|
||
# 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. | ||
|
||
```js | ||
import apisaucePlugin from 'reactotron-apisauce' // <--- import | ||
|
||
// then plug it in when you configure Reactotron. | ||
|
||
Reactotron | ||
.configure() | ||
.use(apisaucePlugin()) // <-- here we go!!! | ||
.connect() | ||
``` | ||
|
||
Next, wherever you create your api for you application, bring in Reactotron and attach the monitor to your apisauce instance. | ||
|
||
```js | ||
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) | ||
}) | ||
``` |
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