0.0.5 • Published 12 months ago

easy-fetch2 v0.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

更新记录

version 0.0.1

目标是让 fetch 发起请求更方便,并且能批量维护请求。

import { Message } from "@arco-design/web-react";
import { createService } from "../lib/service/createService";
import { EasyFetchConfig, ServiceInstance } from "../lib/service";

type ServiceInstanceType = {
  test: ServiceInstance<{ a: number }, { b: number }>;
};

const config: Record<keyof ServiceInstanceType, EasyFetchConfig> = {
  test: {
    url: "/test",
    method: "GET",
  },
};
const service = createService<ServiceInstanceType>(config, {
  async onSuccess(data, response) {
    console.log(data, response);
    Message.success("请求成功");
  },
  async onError(error) {
    Message.error(error.message);
  },
});

service.test({ b: 1 }).then((data) => {
  console.log(data);
});
  • 支持基本的请求功能。
  • 支持 onSuccess 、 onError 的回调函数。
  • 支持 GET 、 POST 请求常规请求。
0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago