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

@koibanx/http

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@koibanx/http

Koibanx's Axios based generic HTTP module

  • 0.0.1
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

HTTP

Koibanx's Axios based generic HTTP module

Installation

Add the dependency to your package.json file by running

npm install @koibanx/http

NOTE: you must have the npm token in your .npmrc file

Usage

Initialize the client by setting the optional default parameters:

  • baseURL: string
  • timeout: number
  • baseHeaders: object
  • requestInterceptors: Array<(request: any) => Promise>
  • responseInterceptors: Array<(response: any) => Promise>

Full example

import http from "@koibanx/http";

const baseURL = "anyurl.com/api"
const timeout = 5000
const baseHeaders = {
    "Authorization": "JWT some-token",
    "Content-Type": "application/json"
}

const logRequestInterceptor = (request) => console.log("Request:", request)
const logResponseInterceptor = (response) => console.log("Response:", response)

const requestInterceptors = [logRequestInterceptor]
const responseInterceptors = [logResponseInterceptor]

// initialize client
const client = http({ baseURL, timeout, baseHeaders, requestInterceptors, responseInterceptors })

const extraHeaders = { "Custom-Header": "SOME_VALUE" }
const foos = await httpGet({url: "/foo", headers: extraHeaders})
console.log("Received foos", foos)

const bar = {
    bar: "bar"
}

const createdBar = await httpPost({url: "/bar", headers: extraHeaders, body: bar})
console.log("Received response", createdBar)



FAQs

Package last updated on 29 Jun 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