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