1.0.0 • Published 6 years ago

artemis-client-axios v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

使用说明

open8200 artemis client axios util for node.js

基于axios的工具包,封装header的签名方法

引入

npm install artemis-client-axios
// commonjs
var client = require('artemis-client-axios');
// es6
import client from 'artemis-client-axios';

API

/**
 * @param {String} appKey
 * @param {String} secret
 */
var cli = client(appKey, secret);

/**
 * @param {String} url 请求地址
 * @param {JSON} config 配置信息
 * {
 *      @param {String} params form表单请求参数
 *      @param {JSON} headers 自定义请求头
 *      @param {JSON} data 非form表单请求信息
 *      @param {JSON} urlParams url中的请求参数
 * }
 */
cli.[get|post|put|delete](url, config)
    .then(response => {})
    .catch(error => {})

示例

let cli = client('23967750', 'BZcz3VlqL1DVhWeF1boE');

cli.post('http://open8200.hikvision.com/artemis/api/vms/v1/setStatus', {
    data: [{ apiId: 71, status: "ONLINE" }],
    headers: {
        'Content-Type': 'application/json;charset=UTF-8'
    }
}) ...

cli.post('http://open8200.hikvision.com/artemis/api/artemis/v1/plus', {
    params: {
        a: 1,
        b: 2
    }
}) ...

cli.get('http://open8200.hikvision.com/artemis/api/artemis/v1/agreementService/securityParam/appKey/{appKey}', {
    urlParams: {
        appKey: 22501409
    }
}) ...


cli.get('http://open8200.hikvision.com/artemis/api/artemis/v1/minus', {
    params: {
        a: 1,
        b: 1
    }
}) ...