# axios-request **Repository Path**: dpapejs/axios-request ## Basic Information - **Project Name**: axios-request - **Description**: Axios does the secondary encapsulation - **Primary Language**: TypeScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-04-01 - **Last Updated**: 2022-07-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: request, Axios, Ajax ## README # @dpapejs/axios-request #### Description A request library based on Axios secondary encapsulation ![npm](https://img.shields.io/npm/v/@dpapejs/axios-request) ![npm](https://img.shields.io/npm/dm/@dpapejs/axios-request) ![NPM](https://img.shields.io/npm/l/@dpapejs/axios-request) #### Install ```shell npm install @dpapejs/axios-request -S ``` #### Quick Start ```js import { createRequest, Get, Post, Put, Del, Form, Download, } from "@dpapejs/axios-request"; createRequest({ baseURL: "http://127.0.0.1:8080", timeout: 30000, headers: { "Content-Type": "application/json", }, setRequest(config) { const token = Cookies.get("Authorization"); const result = {}; if (token) result.Authorization = `Bearer ${token}`; return config; }, requestFail(error) { return Promise.reject(error); }, success(response) { const data = response.data || {}; const statusCode = data.code; if (statusCode !== 200) { return Promise.reject(result); } return data; }, fail(error) { return Promise.reject(error.response || {}); }, }); Get("/api/user/list", { data: { page: 1, pageSize: 10 } }); Post("/api/user/update", { data: { username: "admin", password: "admin456", id: 5 }, }); Put("/api/user/add", { data: { username: "admin", password: "admin123" } }); Form("/api/user/photo", { data: { file: "file date" } }); Del("/api/user/delete/1"); Download("/api/download/execl", { data: { id: "xxxxxxx" } }); Download.post("/api/download/execl", { data: { id: "xxxxxxx" } }); ```