kubo-rpc-client
Version:
A client library for the Kubo RPC API
19 lines (17 loc) • 566 B
text/typescript
import { toUrlSearchParams } from './lib/to-url-search-params.js'
import type { KuboRPCClient } from './index.js'
import type { HTTPRPCClient } from './lib/core.js'
export function createResolve (client: HTTPRPCClient): KuboRPCClient['resolve'] {
return async function resolve (path, options = {}) {
const res = await client.post('resolve', {
signal: options.signal,
searchParams: toUrlSearchParams({
arg: path,
...options
}),
headers: options.headers
})
const { Path } = await res.json()
return Path
}
}