Closed aecc closed 6 years ago
Seems straight-forward. Already tested. It worked as a charm!
add:
JS to add/fetch: const node = new Ipfs({ repo: 'ipfs-' + 1 }); node.once('ready', () => { console.log('Online status: ', node.isOnline() ? 'online' : 'offline'); document.getElementById("status").innerHTML= 'Node status: ' + (node.isOnline() ? 'online' : 'offline');
console.log("IPFS: "); // ADD string node.files.add(new node.types.Buffer('Hello world!'), (err, filesAdded) => { if (err) { return console.error('Error - ipfs files add', err, res) } filesAdded.forEach((file) => console.log('successfully stored', file.hash)) }); // FETCH string node.files.cat('QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY', function (err, data) { console.log("IPFS: " + data); if (err) { console.log('Error - ipfs files cat', err, res) } console.log("data: " + data.toString()) });
Seems straight-forward. Already tested. It worked as a charm!
add:
JS to add/fetch: const node = new Ipfs({ repo: 'ipfs-' + 1 }); node.once('ready', () => { console.log('Online status: ', node.isOnline() ? 'online' : 'offline'); document.getElementById("status").innerHTML= 'Node status: ' + (node.isOnline() ? 'online' : 'offline');