New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@blued-core/http-client

Package Overview
Dependencies
Maintainers
4
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blued-core/http-client

基于 request 的一层封装。

  • 3.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-90.91%
Maintainers
4
Weekly downloads
 
Created
Source

基于 request 的一层封装。

npm i @blued-core/http-client

cache 与 qconf-conf 组件都为可选的,可以自己根据描述自定义

使用方式:

import HttpClient from '@blued-core/http-client'
import Cache from '@blued-core/cache'
import { QconfHost } from '@blued-core/qconf-conf'

const qconfConf = new QconfHost({
  host1: 'XXX'
})

// Cache 可以使用 Map 代替
const httpClient = new HttpClient(qconfConf, new Cache())

const httpClient1 = httpClient.getClient('host1')

async function main () {
  const res = await httpClient1.getData({
    url: 'path1/path2',
    qs: { id: 1 }
  })

  console.log(res)
}

main()

API

调用参数与request参数一致,提供如下八个方法:

基于method抽出来的四个方法:getpostputdelete
基于以上四个方法的基础上处理返回值的四个方法:getDatapostDataputDatadeleteData

两者的区别
httpClient.get({
  url: 'XXX'
}) // => { code: 200, data: 'Hello World' }

httpClient.getData({
  url: 'XXX'
}) // => 'Hello World'

FAQs

Package last updated on 26 Aug 2022

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

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