New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@ebscn/http

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ebscn/http

http beta

latest
npmnpm
Version
1.0.2
Version published
Maintainers
3
Created
Source

http使用指南

1、介绍

1、基于Axios封装的http组件,调用方式保持与Axios一致,新增两个控制参数authorizeOptionerrorHandler

2、authorizeParams适配相应的鉴权方案(目前支持老版本的各种票据ticket以及新版本的jsonWebToken)鉴权信息失效自动更新一次。

3、自定义错误处理函数errorHandler。

4、根据中间件定义的错误码规范处理msg,定位具体服务。

5、业务逻辑错误不按请求错误处理,正常返回。

6、推荐配合adapter使用

2、调用

import { gdHttp } from 'ebscn-http'
gdHttp({
    method: 'get',
    url: '/api',
    authorizeParams: { 'api-token': 'xxx' }  // 鉴权参数,默认为空(JWT为api-tokne的key-value对 票据校验则为票据校验的一系列参数)
    errorHandler: myErrorHandler,  // 自定义错误处理函数,回调参数为返回体中的msg,错误处理函数会在reject前触发,默认为空
    params: {
        'test': 'ebscn'
    }
})
function myErrorHandler(msg) {
    Toast({message: msg})
}
错误码(开头4位)对应服务
9001IAS服务
9002MACS服务
9003ias-balance服务
9100业务中台
9101文件服务
9102验证码服务
9103统一认证
9104一键登录服务
9105逻辑聚合服务

处理后的msg格式为:

“[服务名称]: 具体报错信息,请稍后重试 ”

FAQs

Package last updated on 02 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts