0.0.37 • Published 3 years ago

fast-xhr v0.0.37

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years 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

3 years ago

0.0.36

3 years ago

0.0.35

3 years ago

0.0.33

3 years ago

0.0.30

4 years ago

0.0.29

4 years ago

0.0.28

4 years ago

0.0.27

4 years ago

0.0.26

4 years ago

0.0.25

4 years ago

0.0.24

4 years ago

0.0.23

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.1

4 years ago