When I code for fun, I need to have backend REST API to play with. Usually, I feel too lazy to create a dumb REST API. I have dream about a simple library that I could plug in the frontend with little effort and simulate and persist data somewhere. Then Motivation
How it works?
window.apiand intercept all calls. When a matching call looks like a REST operation then
fotchresponde as you would expect. All data is stored in
npm i fotch
That's it! Seriously, just start using the
fetch API as if there's a REST API. You can stop intercepting calls using
|▶︎ View demo on CodeSandbox|
// Get a list of apples.// Get an apple by id.// Create an apple.// Update an apple.// Remove an apple.
There's only one option that will allow to filter certain calls:
// Filter any call where its URL contains “/api/”.fotchstart'/api/'
If you need more options then request it creating an issue.
- Clone this repo.
- Install dependencies:
- Create a PR.
npm run release npm run release:beta