# @debuggercrafts/storybook-addon-mock-api

> mocking api calls in storybook

Latest version **1.1.0** (published 2019-03-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install @debuggercrafts/storybook-addon-mock-api
pnpm add @debuggercrafts/storybook-addon-mock-api
yarn add @debuggercrafts/storybook-addon-mock-api
bun add @debuggercrafts/storybook-addon-mock-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-03-08 |
| First published | 2019-02-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 370.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | rihdus |
| Maintainers | rihdus |
| Keywords | storybook, fetch, mock |

## Links

- npm: https://www.npmjs.com/package/@debuggercrafts/storybook-addon-mock-api
- Repository: https://github.com/debuggercrafts/storybook-mock-api
- Homepage: https://github.com/debuggercrafts/storybook-mock-api#readme
- Issues: https://github.com/debuggercrafts/storybook-mock-api/issues
- npm.io page: https://npm.io/package/@debuggercrafts/storybook-addon-mock-api

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2019-03-08
- 1.0.1 — 2019-02-10

## README

# Storybook Mock fetch calls [![Build Status](https://travis-ci.org/debuggercrafts/storybook-mock-api.svg?branch=master)](https://travis-ci.org/debuggercrafts/storybook-mock-api)

Mock fetch calls using [mockFetch](http://www.wheresrhys.co.uk/fetch-mock/#api-mockingmock) api.

## Usage

1. Add decorator to [configure mockFetch](http://www.wheresrhys.co.uk/fetch-mock/#usageconfiguration) library.
2. Setup mocks with [mockFetch api](http://www.wheresrhys.co.uk/fetch-mock/#api-mockingmock).

```js
import mockFetch from '../../src/index'

...
storiesOf('About mocking api calls')
  .addDecorator(
    // Configure mockFetch
    mockFetch({
      fallbackToNetwork: true,
      sendAsJson: true,
      overwriteRoutes: false,
    })
  )
  .add('Fetch ',
    () => <button onClick={fetch('api/apples')}>Fetch the call</button>, 
    {
      mockFetch: mockFetch => {
        // Setup mock fetch 
        mockFetch.get('/api/apples', {
          status: 200,
          body: [1, 3, 4],
        })
      },
    }
  )
```

---
_Source: https://npm.io/package/@debuggercrafts/storybook-addon-mock-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
