@sqin/http-axios
v1.0.0
Published
axios 简单封装
Downloads
3
Readme
Axios 简单封装
import { HttpClient } from "@sqin/http-axios";
const { get, post } = new HttpClient({
async urlHook(url) {
return "http://127.0.0.1:3000" + url;
},
async beforeRequest(option) {
return option;
},
async responsePass(res) {
return res.data;
},
async responseFail({ err, res }) {
return res?.data;
},
});
get("/api/xxx", { id: 123 });
post("/api/zzz", { user: "abc" });
// 可以随时覆盖默认处理
post(
"/api/yyy",
{ user: "abc" },
{
async urlHook(url) {
return "http://127.0.0.1:4000" + url;
},
}
);