https://github.com/zeelyn/rest.request
https://github.com/zeelyn/rest.request
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zeelyn/rest.request
- Owner: ZeeLyn
- License: mit
- Created: 2020-12-15T05:42:58.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-12-11T09:06:40.000Z (about 3 years ago)
- Last Synced: 2025-07-21T14:12:28.012Z (5 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rest.request
## Configuration
Add .env.dev file
```
NODE_ENV = 'development'
VUE_APP_API_BASE_URL = 'development domain'
```
Add .env.prod file
```
NODE_ENV = 'production'
VUE_APP_API_BASE_URL = 'production domain'
```
## Usage
### 1.Modify main.js
```javascript
import request from "@g1100100/rest.request"
Vue.prototype.$http = request;
```
### 2.Configure default options
```javascript
request.defaults({
})
```
### 3.Request api
```javascript
this.$http.post("url",{
data:{
name:"test"
}
}).then(res=>{
console.inf(res.data);
});
```
## Options
|Option|Type|Description|
|--|--|--|
|$400|function|Called when the response status code is 400|
|$401|function|Called when the response status code is 401|
|$403|function|Called when the response status code is 403|
|$404|function|Called when the response status code is 404|
|$catch|function|Called when the response status code is not in the above list|
|$finally|function|No matter what the response result is, it will be called|