@lidofinance/rpc v0.43.0
@lidofinance/rpc
Fetch extension to use it with RPC endpoints.
Installation
yarn add @lidofinance/rpc
Getting started
You can just use it as normal fetch
, there are just a few types restrictions, and it will set right HTTP method for
you.
fetchRPC(url, { body: req.body })
Examples
Caching
Here is an example how you can extend fetchRpc
by adding caching
import { FetchRpc, fetchRpc } from '@lidofinance/rpc'
import { Cache } from 'memory-cache'
export type CachedFetchRPC = FetchRpc<{ cacheKey: string }>
// Just a sample how to use extend fetchRPC
export const cachedFetchRpcFactory = (timeout: number): CachedFetchRPC => {
const cache = new Cache<string, Response>()
return async (url, init, { cacheKey }) => {
const cachedValue = cache.get(cacheKey)
if (cachedValue != null) {
return cachedValue
}
const response = await fetchRpc(url, init)
cache.put(cacheKey, response, timeout)
return response
}
}
14 days ago
2 months ago
2 months ago
3 months ago
5 months ago
7 months ago
8 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
1 year ago
11 months ago
11 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago