0.0.37 • Published 2 years ago

fast-xhr v0.0.37

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

2 years ago

0.0.36

2 years ago

0.0.35

2 years ago

0.0.33

2 years ago

0.0.30

3 years ago

0.0.29

3 years ago

0.0.28

3 years ago

0.0.27

3 years ago

0.0.26

3 years ago

0.0.25

3 years ago

0.0.24

3 years ago

0.0.23

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.1

3 years ago