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'
const service = new HttpService({
parseJson: true,
retry: 3
})
interface ExpectedBody {
completed: boolean
id: number
title: string
userId: number
}
const res = await service.get<ExpectedBody>({ url: `https://jsonplaceholder.typicode.com/todos/1` })