0.1.13 • Published 3 years ago

@postnord/http-service v0.1.13

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
3 years ago

Introduction

A wrapper around got that gives a higher-level interface with generics.

Features

  • Pleasant interface where you pass in objects to all methods, making it more readable.
  • Generics to define the expected response body.
  • Default options set upfront that could be overridden on individual calls, DRYing your code while making it flexible when needed.

Quick start

import HttpService from '@postnord/http-service'
 

/**
 * You could optionally instantiate the service with default config.
 * Each config can be overridden on individual calls to methods.
**/
const service = new HttpService({
  parseJson: true,
  retry: 3
})

/**
 * You could define what body you're expecting to get
 **/

interface ExpectedBody {
  completed: boolean
  id: number
  title: string
  userId: number
}
const res = await service.get<ExpectedBody>({ url: `https://jsonplaceholder.typicode.com/todos/1` })

// res.responseBody will be typed as ExpectedBody
0.1.13

3 years ago

0.1.11

3 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago