dd-http
v1.0.3
Published
dd-http
Downloads
2
Maintainers
Readme
dd-http
Project setup
npm install dd-http --save-dev;
or
yarn install dd-http --save-dev;
Syntax
t = new Date().valueOf();
GET:
params:
type: Object
exp:
{ page: 1, size: 10 }
/api/demo?page=1&size=10&t=t
GETQUERY:
params:
type: Object
exp:
{ page: 1, size: 10 }
/api/demo/1/10?t=t
POST:
params:
type: Object
exp:
{ page: 1, size: 10 }
/api/demo?t=t
PUT:
params:
type: Object
exp:
{ page: 1, size: 10 }
/api/demo?t=t
DELETE:
params:
type: Object
exp:
{ page: 1, size: 10 }
/api/demo?t=t
Cite
mkdir demo.js
import apiFactory from 'dd-http';
const demo = [
{
name: 'demoList',
url: '/demo/list',
method: 'post'
}
];
export default apiFactory(demo);
Employ
import demoApi from '***/demo.js';
let params = { page: 1, size: 10 };
let { data, code } = await demoApi.demoList(params);
if(code === 0){
// To Do Somethings
}
Customize configuration
See API.