radi-fetch
radi-fetch
is the official HTTP client for Radi.js. It deeply integrates with Radi for seamless application building.
Installation
To install the stable version:
npm install --save radi-fetch
This assumes you are using npm as your package manager.
If you're not, you can access these files on unpkg, download them, or point your package manager to them.
Browser Compatibility
radi-fetch
currently is compatible with browsers that support ES5.
Getting started
Here is how it works. We start by initiating plugin for Radi Radi.plugin(/* radi-fetch */, /* config */)
. Config here is optional, but we can define crucial parts of http client.
import RadiFetch from 'radi-fetch' Radi
or
import RadiFetch from 'radi-fetch' Radi;
That's it, we're ready to go. We can start fetching our api or whatever we want by using fetch by $fetch[type](url, params, headers)
handle.
Response can be automatically parsed as JSON by using .json()
method, or .text()
for plain text response.
Component { return { this$fetch } }
Fetch automatically sets loading state for any ongoing request. We can listen to them in radi using $loading
handle.
/* @jsx Radi.r */ Component { return <ul> <li>/api is this$loadingstate'/api' ? 'loading' : 'ready' </li> <li>Number of active requests: this$loadingstate$count </li> <li>Anything loading: this$loadingstate$any </li> </ul> }
Stay In Touch
License
Copyright (c) 2018-present, Marcis (Marcisbee) Bergmanis