1.0.3 • Published 12 months ago

bitverse-http-client v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

BitversehttpClient 网络请求库

适用于网关验签的http接口请求

usage

// 引入
import httpClient from 'bitverse-http-client';
export const baseURLMainNet = 'https://api.bitverse.zone';

// 需要签名的接口
const apiUrl = `${baseURLMainNet}/bitverse/bitdapp/v1/public/quest/activity/get`;

// demo1
const testHttpRequest1 = async () => {
  try {
    /**
     * 参数1: 接口完整url
     * 参数2: post body
     * 参数3:  自定义header
     */
    const result = await httpClient.post(apiUrl, {
      activityId: '123456',
    },
    console.log('[response ok]:', result);
  } catch (error) {
    console.log('[response error]: ', error);
  }
};

// demo2
const testHttpRequest2 = async () => {
  try {
    /**
     * 参数1: 接口完整url
     * 参数2: post body
     * 参数3:  自定义header
     */
    const result = await httpClient.post(apiUrl, {
      activityId: '123456',
    },
    {
      userToken: 'eyJ0eXxxxxs',
    });
    console.log('[response ok]:', result);
  } catch (error) {
    console.log('[response error]: ', error);
  }
};

develop

# 安装依赖
yarn

# 开发运行
yarn dev

# 构建
yarn build
1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago