Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rjgf/http-client

Package Overview
Dependencies
Maintainers
7
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rjgf/http-client - npm Package Compare versions

Comparing version 0.1.18 to 0.1.19

9

dist/index.d.ts

@@ -14,3 +14,3 @@ import { AxiosRequestConfig, AxiosResponse } from 'axios';

}
export interface HTTPEventTypes {
interface HTTPEventTypes {
error: (err: HTTPError) => void;

@@ -61,3 +61,3 @@ 'not-login': (err: HTTPError) => void;

url?: string | undefined;
method?: "link" | "get" | "GET" | "delete" | "DELETE" | "head" | "HEAD" | "options" | "OPTIONS" | "post" | "POST" | "put" | "PUT" | "patch" | "PATCH" | "purge" | "PURGE" | "LINK" | "unlink" | "UNLINK" | undefined;
method?: import("axios").Method | undefined;
baseURL?: string | undefined;

@@ -75,3 +75,3 @@ transformRequest?: import("axios").AxiosTransformer | import("axios").AxiosTransformer[] | undefined;

auth?: import("axios").AxiosBasicCredentials | undefined;
responseType?: "arraybuffer" | "blob" | "document" | "json" | "text" | "stream" | undefined;
responseType?: import("axios").ResponseType | undefined;
xsrfCookieName?: string | undefined;

@@ -112,3 +112,4 @@ xsrfHeaderName?: string | undefined;

*/
static isLoginFail(response: AxiosResponse): boolean;
private static isLoginFail;
}
export {};

@@ -17,3 +17,5 @@ "use strict";

const axios_1 = __importDefault(require("axios"));
// eslint-disable-next-line import/no-named-as-default
const eventemitter3_1 = __importDefault(require("eventemitter3"));
// eslint-disable-next-line import/no-unused-modules
class HTTPError extends Error {

@@ -33,2 +35,38 @@ constructor(message, _code, _response) {

exports.HTTPError = HTTPError;
const client = axios_1.default.create();
// @ts-expect-error 如果是 uni-app 的话,加上对应的适配器
if (typeof uni === 'object') {
client.defaults.adapter = function (config) {
// 自己定义个适配器,用来适配 uniapp 的语法
return new Promise((resolve, reject) => {
var _a;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const settle = require('axios/lib/core/settle');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const buildURL = require('axios/lib/helpers/buildURL');
// @ts-expect-error ignore
uni.request({
method: (_a = config.method) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
url: config.baseURL + buildURL(config.url, config.params, config.paramsSerializer),
header: config.headers,
data: config.data,
// @ts-expect-error ignore
dataType: config.dataType,
responseType: config.responseType,
// @ts-expect-error ignore
sslVerify: config.sslVerify,
complete: function complete(response) {
const res = {
data: response.data,
status: response.statusCode,
errMsg: response.errMsg,
header: response.header,
config: config,
};
settle(resolve, reject, res);
},
});
});
};
}
// eslint-disable-next-line import/no-unused-modules

@@ -38,3 +76,3 @@ class HTTPClient extends eventemitter3_1.default {

super();
this.client = axios_1.default.create();
this.client = client;
this.client.defaults.baseURL = baseURL;

@@ -41,0 +79,0 @@ this.client.defaults.headers.common.Pragma = 'no-cache';

@@ -20,3 +20,3 @@ {

],
"gitHead": "5862d5ff45549b697c872b9e5bdc58f04d6dbfd8",
"gitHead": "f5411f2e7ed46b355aa778d5ef7fd1688b87bc50",
"license": "Apache-2.0",

@@ -35,3 +35,3 @@ "main": "./dist/index.js",

},
"version": "0.1.18"
"version": "0.1.19"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc