An opinionated Fetch wrapper for JSON APIs
npm install @antoinette-agency/sofetch
Quick Start |
Examples |
API
npm i @antoinette-agency/sofetch
`
$3
`typescript
import soFetch from "@antoinette-agency/sofetch";
//GET Request:
const products = await soFetch("/api/products")
//POST Request:
const newUser = {
name:"Regina George",
email:"regina@massive-deal.com"
}
const successResponse = await soFetch("/api/users", newUser)
//Handling errors
const unicorn = await soFetch("/api/unicorns/1234")
.catchHttp(HttpStatus.NotFound404, (res:Response) => {
alert("This unicorn can't be found")
})
``