All Projects → tkh44 → Holen

tkh44 / Holen

Licence: mit
Declarative fetch for React

Programming Languages

javascript
184084 projects - #8 most used programming language
declarative
70 projects

Projects that are alternatives of or similar to Holen

Ngx Restangular
Restangular for Angular 2 and higher versions
Stars: ✭ 787 (+417.76%)
Mutual labels:  fetch, request, response
Wretch Middlewares
Collection of middlewares for the Wretch library. 🎁
Stars: ✭ 42 (-72.37%)
Mutual labels:  fetch, request
Create Request
Apply interceptors to `fetch` and create a custom request function.
Stars: ✭ 34 (-77.63%)
Mutual labels:  fetch, request
Netclient Ios
Versatile HTTP Networking in Swift
Stars: ✭ 117 (-23.03%)
Mutual labels:  request, response
Guzzlette
🌀 Guzzle integration into Nette Framework (@nette)
Stars: ✭ 19 (-87.5%)
Mutual labels:  request, response
Composable Fetch
A library that brings composition to http requests & solves most common tasks
Stars: ✭ 23 (-84.87%)
Mutual labels:  fetch, request
Redux Query
A library for managing network state in Redux
Stars: ✭ 1,055 (+594.08%)
Mutual labels:  fetch, request
Swiftyjson
The better way to deal with JSON data in Swift.
Stars: ✭ 21,042 (+13743.42%)
Mutual labels:  request, response
Aura.http
HTTP Request and Response tools
Stars: ✭ 69 (-54.61%)
Mutual labels:  request, response
Mfetch
mfetch will provide you with a strong ability to request resource management
Stars: ✭ 90 (-40.79%)
Mutual labels:  fetch, request
Apipeline
Feature-rich and pluggable offline-first API wrapper for all your javascript environements ! Easily wire-up your API and make your app work offline in minutes.
Stars: ✭ 92 (-39.47%)
Mutual labels:  fetch, request
Kitura Net
Kitura networking
Stars: ✭ 98 (-35.53%)
Mutual labels:  request, response
Ky
🌳 Tiny & elegant JavaScript HTTP client based on the browser Fetch API
Stars: ✭ 7,047 (+4536.18%)
Mutual labels:  fetch, request
Alamofire
Elegant HTTP Networking in Swift
Stars: ✭ 36,896 (+24173.68%)
Mutual labels:  request, response
Fast Cgi Client
A PHP fast CGI client for sending requests (a)synchronously to PHP-FPM
Stars: ✭ 478 (+214.47%)
Mutual labels:  request, response
Frisbee
🐕 Modern fetch-based alternative to axios/superagent/request. Great for React Native.
Stars: ✭ 1,038 (+582.89%)
Mutual labels:  fetch, request
Wiremock.net
WireMock.Net is a flexible library for stubbing and mocking web HTTP responses using request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
Stars: ✭ 408 (+168.42%)
Mutual labels:  request, response
Ky Universal
Use Ky in both Node.js and browsers
Stars: ✭ 421 (+176.97%)
Mutual labels:  fetch, request
Alagarr
🦍 Alagarr is a request-response helper library that removes the boilerplate from your Node.js (AWS Lambda) serverless functions and helps make your code portable.
Stars: ✭ 58 (-61.84%)
Mutual labels:  request, response
Php Fetch
A simple, type-safe, zero dependency port of the javascript fetch WebApi for PHP
Stars: ✭ 95 (-37.5%)
Mutual labels:  fetch, response

Holen

Declarative fetch in React

npm version Build Status codecov

Install

npm install -S holen

Basic Usage

// Fetch on mount
<Holen url="api.startup.com/users">
  {({data}) => <pre>{JSON.stringify(data, null, 2)}</pre>}
</Holen>

// Lazy fetch
<Holen lazy onResponse={handleResponse} url="api.startup.com/users">
  {({fetching, data, fetch, error}) => (
    <div>
      <button onClick={fetch}>Load Data</button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  )}
</Holen>

Props

body any

<Holen
  body={JSON.stringify({ message: 'hello' })}
  method="POST"
  url="api.startup.com/users"
>
  {({data}) => <pre>{JSON.stringify(data, null, 2)}</pre>}
</Holen>

MDN - Body

children function

Children is a function that receives an object as its only argument.

The object contains the following keys:

  • fetching: bool
  • response: object
  • data: object
  • error: object
  • fetch: function
<Holen url="api.startup.com/users">
  {({data}) => <div>{data.name}</div>}
</Holen>

credentials string

MDN - Credentials

headers string

MDN - Headers

lazy boolean

If true then the component will not perform the fetch on mount. You must use the fetch named argument in order to initiate the request.

<Holen lazy url="api.startup.com/users">
  {({fetching}) => {fetching && <div>Loading</div>}} // renders nothing, fetch was not started
</Holen>

method string - default GET

MDN - Method

onResponse function

callback called on the response.

const handleResponse = (error, response) => {
  if (error || !response.ok) {
    panic()
  }

  cheer()
}

<Holen
  lazy
  onResponse={handleResponse}
  url="api.startup.com/users">
  {({ data, fetch }) => (
    <div>
      <button onClick={fetch}>Load Data</button>
      <pre>{JSON.stringify(data, null , 2)}</pre>
    </div>
  )}
</Holen>

transformResponse function - default data => data

The transformResponse prop is a function that can be used to massage the response data. It receives one argument, data, and by default, performs an identity operation, returning the data passed to it.

type string - default json

The body method applied to the response. One of json, text, blob, arrayBuffer or formData.

url string

url of the request.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].