@zeelyn/http
v1.0.2
Published
```ps1 npm install @zeelyn/http ```
Downloads
3
Readme
@zeelyn/http
Project setup
npm install @zeelyn/http
Global configuration
import http from "@zeelyn/http";
http.defaults((config) => {
config.baseURL = "https://www.google.com";
config.$on_before_request = (options) => {
options.headers["Authorization"] = "Bearer " + localStorage.getItem("access_token");
};
config.$401 = () => {
console.log("Request failed with status code 401");
};
config.$finally = () => {
console.log("finally exec");
};
config.$error_network=(err)=>{
console.error("network error ", err);
}
});
Request url
http.get("/api/test",{})
.then((res) => {
console.log("ok=>", res.data);
})
.catch((err) => {
console.error(err);
});