react-native-fetch-mock

码农软件 · 软件分类 · React 开源项目 · 2019-04-28 05:58:36

软件介绍

在使用 React Native 的过程中,没有找到一款合适自己的 fetch-mock 组件。

因此,决定自己发布一个 react-native-fetch-mock module。

Roadmap

1. 结合Mock.js(已实现)

2. 配合线上rap系统

Usage

__ mocks__/index.js

export default {
  '/api/path': (options) => {
    const all = Mock.mock({
      'list|2': [{
        'id|+1': 1,
        'name': '@first @last',
        'age|18-54': 1,
      }]
    }).list;
    return Promise.resolve({
      data: all,
    });
  }
}

index.js

import FetchMock from 'react-native-fetch-mock';

if (__dev__) {
  global.fetch = new FetchMock(require('path/to/mocks/directory')).fetch;
}

// if __dev__ is true, it will back the data you defined in mock directory
fetch('/api/path', options);

本文地址:https://codercto.com/soft/d/4540.html

The Probabilistic Method

The Probabilistic Method

Noga Alon、Joel H. Spencer / Wiley-Interscience / 2008-8-11 / USD 137.00

Praise for the Second Edition : "Serious researchers in combinatorics or algorithm design will wish to read the book in its entirety...the book may also be enjoyed on a lighter level since the diffe......一起来看看 《The Probabilistic Method》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

html转js在线工具
html转js在线工具

html转js在线工具