ipfs-http-client
Version:
A client library for the IPFS HTTP API
18 lines • 552 B
JavaScript
import { CID } from 'multiformats/cid';
import { configure } from '../lib/configure.js';
import { toUrlSearchParams } from '../lib/to-url-search-params.js';
export const createNew = configure(api => {
async function newObject(options = {}) {
const res = await api.post('object/new', {
signal: options.signal,
searchParams: toUrlSearchParams({
arg: options.template,
...options
}),
headers: options.headers
});
const {Hash} = await res.json();
return CID.parse(Hash);
}
return newObject;
});