siomai
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

siomai

API calls made simple for Bun.

Install

bun add siomai

Usage

import siomai from 'siomai'

const data = await siomai.post('https://example.com', {
  json: {
    foo: true
  }
})

With plain fetch, it would be:

class HTTPError extends Error {}

const response = await fetch('https://example.com', {
  method: 'POST',
  body: JSON.stringify({ foo: true }),
  headers: {
    'content-type': 'application/json'
  }
})

if (!response.ok) {
  throw new HTTPError('Error while fetching https://example.com', response)
}

const data = await response.json()

console.log(data)

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i siomai

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

8.16 kB

Total Files

6

Last publish

Collaborators

  • wobsoriano