@zeelyn/rest.request

2.0.0 • Public • Published

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

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

Readme

Keywords

none

Package Sidebar

Install

npm i @zeelyn/rest.request

Weekly Downloads

0

Version

2.0.0

License

MIT

Unpacked Size

6.19 kB

Total Files

6

Last publish

Collaborators

  • kakous