0.3.0 • Published 1 year ago

dretch v0.3.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
1 year ago

dretch

Data-Driven Fetch API

Why?

Easier, data-driven syntax

This:

const request = dretch('https://jsonplaceholder.typicode.com')

const response = await request("POST", "/todos", {
  body: { title: "Remember the milk" }
})

instead of this:

const response = await fetch("https://jsonplaceholder.typicode.com/todos", {
  method: "POST",
  headers: { 
    "Content-Type": "application/json" 
  },
  body: JSON.stringify({ title: "Remember the milk" })
})

Use JavaScript data structures to describe requests

const request = dretch('https://jsonplaceholder.typicode.com')

const req = ['POST', '/todos', { 
  body: {
    title: "Remember the milk"
  }
}] as RequestData

const response = await request(...req)
0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago