UNPKG

kubo-rpc-client-esm-cjs

Version:
28 lines (23 loc) 618 B
import { configure } from '../lib/configure.js' import { toUrlSearchParams } from '../lib/to-url-search-params.js' export const createGet = configure(api => { /** * @type {import('../types.js').ConfigAPI["get"]} */ const get = async (key, options = {}) => { if (!key) { throw new Error('key argument is required') } const res = await api.post('config', { signal: options.signal, searchParams: toUrlSearchParams({ arg: key, ...options }), headers: options.headers }) const data = await res.json() return data.Value } return get })