2.0.0 • Published 1 year ago

@zeelyn/rest.request v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

import request from "@g1100100/rest.request"
Vue.prototype.$http = request;

2.Configure default options

request.defaults({

})

3.Request api

this.$http.post("url",{
    data:{
        name:"test"
    }
}).then(res=>{
    console.inf(res.data);
});

Options

OptionTypeDescription
$400functionCalled when the response status code is 400
$401functionCalled when the response status code is 401
$403functionCalled when the response status code is 403
$404functionCalled when the response status code is 404
$catchfunctionCalled when the response status code is not in the above list
$finallyfunctionNo matter what the response result is, it will be called