Last active
January 30, 2019 18:37
-
-
Save offirgolan/94503d60563512de8b3d6783ceafe798 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
Create a new polly instance. | |
Connect Polly to fetch. By default, it will record any requests that it | |
hasn't yet seen while replaying ones it has already recorded. | |
*/ | |
const polly = new Polly('Simple Example', { | |
adapters: ['fetch'], // Hook into `fetch` | |
persister: 'local-storage', // Read/write to/from local-storage | |
}); | |
/* Any networks requests here using fetch will be handled by the Polly instance. */ | |
await fetch('/posts/1'); | |
/* Calling `stop` will persist requests as well as disconnect from any connected adapters. */ | |
await polly.stop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment