Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save okstaticzero/3bcde0ca318386c1b09fa0dfec74bd17 to your computer and use it in GitHub Desktop.
Save okstaticzero/3bcde0ca318386c1b09fa0dfec74bd17 to your computer and use it in GitHub Desktop.
const IPFS = require('ipfs-mini');
const ipfs = new IPFS({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });
export const setJSON = (obj) => {
return new Promise((resolve, reject) => {
ipfs.addJSON(obj, (err, result) => {
if (err) {
reject(err)
} else {
resolve(result);
}
});
});
}
export const getJSON = (hash) => {
return new Promise((resolve, reject) => {
ipfs.catJSON(hash, (err, result) => {
if (err) {
reject(err)
} else {
resolve(result)
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment