0.0.37 • Published 1 year ago

fast-xhr v0.0.37

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

fast-xhr

Install

npm install fast-xhr

How to use

import { XHR, Result, Response } from "fast-xhr";

interface Images {
  total: number,
    list: { id: number, url: string, name: string }[]
}

type ImagesResponse = Response<Result<Images>>

const xhr = new XHR<Response>({
  baseURL: "http://localhost:6060",
});

xhr.axios.interceptors.response.use(function(response) {
  // const { data } = response;
  return response;
}, function(error) {
  throw error;
});

xhr.post("/api/image/list")
  .withBody({
    pageIndex: 1,
    pageSize: 10,
  })
  .setHeaders({
    "custom-headers": "fast-xhr",
  })
  .setContentType("application/json")
  .response<ImagesResponse>((res) => {
    console.log(res.data.data.list);
  }, (error) => {
    console.log(error.message);
  });
0.0.37

1 year ago

0.0.36

1 year ago

0.0.35

1 year ago

0.0.33

1 year ago

0.0.30

1 year ago

0.0.29

1 year ago

0.0.28

1 year ago

0.0.27

1 year ago

0.0.26

1 year ago

0.0.25

1 year ago

0.0.24

1 year ago

0.0.23

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

2 years ago

0.0.1

2 years ago