npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

haigeek-axios

v1.1.4

Published

海极网网关请求插件

Downloads

40

Readme

haigeek-axios请求插件

介绍

基于axios封装,适用于调用海尔对外开放能力的http请求插件。

安装

npm install haigeek-axios

示例

import { haigeekRequest } from 'haigeek-axios'
haigeekRequest('get', url, params).then(res => {})
import axios from 'haigeek-axios'
axios......

封装

import { haigeekRequest } from '@/assets/js/http'
const env = process.env.NODE_ENV
export const baseapi = env === 'development' ? '/apiprod' : 'https://ys-openservice.haigeek.com'
/**
  * @description: 封装请求类
  * @param {method} method 请求方式
  * @param {path} path 请求路径
  * @param {params} params 参数
  * @param {headers} headers 请求头
  */
export const iotRequest = (method, path, params, headers) => {
    return haigeekRequest(
        method,
        baseapi + path,
        params,
        {
            hgAppId: 'MB-IYD10511011511-0000',
            hgAppKey: '08764dc218830a9a05cbfa1814020cdf',
            hgUrlPrefix: baseapi,
            hgLoading: true, 
            hgAutoError: '1',
            hgSuccessCodeKey: 'retCode', // 默认retCode,可不传
            hgSuccessCode: '00000', // 默认00000,可不传
            hgErrorMsgKey: 'retInfo', // 默认retInfo,可不传
            hgEncryptLevel: '0', // 默认0,可不传
            hgLoginCode: '403',
            fnShowError: fnShowError,
            fnStartLoading: fnStartLoading,
            fnEndLoading: fnEndLoading,
            fnLogin: fnLogin
        },
        headers
    )
}
const fnStartLoading = () => {
    document.getElementById('loading').style.display = 'block';
}
const fnEndLoading = () => {
    document.getElementById('loading').style.display = 'none';
}
const fnShowError = (msg) => {
    document.getElementById('showMsg').innerHTML = msg;
    document.getElementById('showMsg').style.display = 'block';
    setTimeout(() => {
        document.getElementById('showMsg').style.display = 'none';
    }, 3000);
}
const fnLogin = () => {
    console.log('跳转至登录')
}

// 使用
import { iotRequest } from '@/api/api.js'
iotRequest(
  'post',
  '接口地址',
  {
    "参数1":"111",
  }
).then(res => {
  console.log(res)
}).catch(e => {
  console.log(e)
})

haigeekRequest(method, ajaxurl, params, config, headers, other): 说明

method

请求方式:get/post

ajaxurl

请求地址

params

入参:json类型(其他类型时通过config.hgEncryptLevel控制) HOtherype: 非json类型入参时可通过该参数传入

config主要配置项

1>hgAppId:string

对应智能应用appId, 验证签名-必传

2>hgAppKey:string

对应智能应用appKey, 验证签名-必传

3>hgAutoError:string

0:不自动提示(默认值)

1:自动提示后台异常信息(注意需要传fnShowError)

4>hgLoading:bool

false:请求时不显示loading(默认值)

true:请求时自动显示loading(注意需要传fnStartLoading,fnEndLoading)

5>hgEncryptLevel:string

0:入参为json类型数据(默认值)

1:入参为application/x-www-form-urlencoded类型数据

2:入参为multipart/form-data类型数据

6>hgHeadSignLog:bool

false:不打印header参数sign(默认值)

true:打印header参数sign(用于调试)

7>hgSuccessCodeKey:string | number

'retCode': 默认值

其他:自定义code的key

8>hgSuccessCode:string | number

'00000': 默认值

其他:自定义请求成功code值

9>hgErrorMsgKey: string

'retInfo': 默认值

其他:自定义请求失败错误信息key值

10>hgUrlPrefix: string

请求前缀--签名时去除使用,生产环境一般传域名

11>fnStartLoading: function

打开loading

12>fnEndLoading: function

关闭loading

13>fnShowError: function

自动错误提示方法,参数为提示的错误信息

14>hgLoginCode: string

用户信息失效,需要登录使用;登录失效返回的code值(默认不自动登录)

15>fnLogin: function

自动跳转登录方法

16>hgErrorType: string

接口报错类型:不传:接口必须正常返回,通过code值判断是否请求失败(默认值),1:接口请求失败时直接返回错误信息

17>hgSuccessResult: string

请求成功返回结果对应的属性数据,默认无(返回整个结果数据)