@lighthouse-web3/sdk
Version:
NPM package and CLI tool to interact with lighthouse protocol
33 lines (32 loc) • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const lighthouse_config_1 = require("../../lighthouse.config");
exports.default = async (cid, key, apiKey) => {
try {
const url = lighthouse_config_1.lighthouseConfig.lighthouseAPI +
`/api/ipns/publish_record?cid=${cid}&keyName=${key}`;
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: `Bearer ${apiKey}`,
},
});
if (!response.ok) {
throw new Error(`Request failed with status code ${response.status}`);
}
const data = (await response.json());
/*
return:
{
data: {
"Name": "k51qzi5uqu5dm6uvby6428rfpcv1vcba6hxq6vcu52qtfsx3np4536jkr71gnu",
"Value": "/ipfs/Qmd5MBBScDUV3Ly8qahXtZFqyRRfYSmUwEcxpYcV4hzKfW"
}
}
*/
return { data: data };
}
catch (error) {
throw new Error(error.message);
}
};