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 🙏

© 2026 – Pkg Stats / Ryan Hefner

iboot-http-client

v1.4.8

Published

iBoot.xin 相关应用的客户端Http封装

Downloads

120

Readme

iboot-http-client

中文简介:

iboot-http-client 是一个轻量的 HTTP 客户端库,旨在帮助开发者快速接入并使用 iCMS 系统的 API。它封装了常见的请求/响应处理、鉴权与类型声明,适用于 TypeScript 在浏览器或 Node.js 环境中的调用场景。

English Summary:

iboot-http-client is a lightweight HTTP client library designed to help developers quickly integrate with the iCMS system API. It wraps common request/response handling, authentication and TypeScript typings for both browser and Node.js usage.

主要目标 / Goals

  • 简化调用 iCMS API 的流程 / Simplify calling iCMS APIs
  • 提供 TypeScript 类型支持 / Provide TypeScript typings
  • 支持全局配置、拦截器与鉴权扩展 / Support global config, interceptors and auth

特性 / Features

  • 基于 Fetch 封装,兼容浏览器与 Node(可按需替换实现) / Built on Fetch, compatible with browser and Node (swapable)
  • 全局 baseURL、默认 headers、自动注入 token / Global baseURL, default headers, automatic token injection
  • 请求/响应拦截器支持 / Request/response interceptor support
  • 类型声明文件位于 index.d.ts / Type declarations available in index.d.ts

安装 / Install

使用 npm:

npm install iboot-http-client

或使用 pnpm / yarn:

pnpm add iboot-http-client
yarn add iboot-http-client

快速开始 / Quick Start

示例(TypeScript):

import { HttpClient } from 'iboot-http-client'

const client = new HttpClient()

// GET example
const list = await client.get('/articles', { data: { page: 1, pageSize: 10 } })

// POST example
const created = await client.post('/articles', { data:title: 'Example', body: 'Content' })

console.log(list, created)

更多方法签名与配置请参阅 src/HttpClient.tsindex.d.ts

配置项 / Options

  • deviceId:客户端设备id(可选),不填会缓存一个随机数
  • lang:语言(可选),不填默认zh-CN
  • websiteId:websiteId(网站ID,icms系统调用时可用,不填为icms设置的默认网站)
  • websiteNo:websiteNo(网站编号,icms系统调用时可用, 不填为icms设置的默认网站),
  • userType:客户端用户类型0:营运用户,1:C端用户,2.B端用户

错误处理 / Error Handling

客户端在网络错误或非 2xx 响应时会抛出异常。请使用 try/catch 处理:

try {
	await client.get('/protected')
} catch (err) {
	// handle auth failure, network error or business errors
}

环境变量

.env.development / .env.production

APP_NAME=iCMS
APP_ENV=production
APP_APIKEY=
APP_BASEURL=http://localhost:8081
#用户来源
#1.PCweb
#2.PC桌面应用
#3.微信小程序
#4.微信公众号
#5.企业微信
#6.手机APP
APP_USERFROM=1

注意,如在生产环境不能获取以上环境变量,你可以在 shell 配置文件中设置环境变量,例如 .bashrc 或 .profile 导入环境变量

export APP_NAME="icms"
export APP_ENV="production"
export APP_APIKEY="xxx"
APP_BASEURL=http://localhost:8081

开发与贡献 / Contributing

  • 欢迎提交 issue 或 PR。请在 issue 中描述重现步骤与期望行为。
  • 新特性建议请先在 issue 中讨论。

本项目遵循仓库根目录的 LICENSE 文件。


如需我将 README 中的中文或英文内容扩展为更详细的使用示例(例如:鉴权流程、拦截器实现、错误码映射),或把 README 同步到包的 package.jsonhomepagerepository 字段,请告诉我。