@increments/request
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@increments/request

NPM version Build Status Maintainability Test Coverage Stable Release Size

Minimalistic XHR wrapper. Zero dependency.

Installation

If your project is using npm, you can install @increments/request package by npm command:

npm install --save @increments/request
# or
yarn add @increments/request

Distribution files

  • dist/index.js - The CommonJS version of this package. (default)
  • dist/index.es.js - The native modules version of this package.
  • dist/request.es5.js - ES5 / UMD version of this package. This version exports itself to window.Request.

Synopsis

import { request } from "@increments/request"

request("POST", "/api/endpoint", {
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json;charset=UTF-8"
  },
  data: requestPayload
}).then(response => {
  //
}).catch(error => {
  //
})

TypeScript

// Declare type of response.data
request<{ users: { name: string }[] }>("GET", "/users")
  .then(response => {
    console.log(response.data.users[0].name) // Show first user's name.
  })

Readme

Keywords

none

Package Sidebar

Install

npm i @increments/request

Weekly Downloads

2

Version

0.1.0

License

MIT

Unpacked Size

187 kB

Total Files

22

Last publish

Collaborators

  • increments_org