0.1.1 • Published 1 year ago

use-taro-request v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

use-taro-request

use-taro-request 是基于 taro 及 react 开发的主要用于网络请求的 hooks。

npm npm downloads npm license npm bundle size npm type definitions

Installation / 安装

npm

npm install use-taro-request --save

yarn

yarn add use-taro-request

Config / 配置

使用 taroRequestConfig 在程序入口文件,app.tsx或者main.ts等中导入并全局配置

import { taroRequestConfig } from "use-taro-request";

taroRequestConfig({
  baseUrl: "https://example.com",
  header: {}
  // ...
});

Usage / 使用

import { useTaroRequest } from "use-taro-request";

const { data, loading, error, refetch } = useTaroRequest({ url: "/list" });

manual / 手动触发请求

通过 manual 属性配置依赖请求,当传入 true 时,将需要自己手动触发 refetch

import { useTaroRequest } from "use-taro-request";

const { data, loading, error, refetch } = useTaroRequest(
  {
    url: "/list",
    params: {
      //...
    }
  },
  { manual: true }
);

taro 请求配置

PropertyTypeDefaultDescription
baseUrlstring''基础网络地址
headerobject{}请求头
timeoutnumber0请求 timeout

taro request hooks 配置

PropertyTypeDefaultDescription
manualbooleanfalse是否手动触发请求
0.1.1

1 year ago

0.1.0

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago