ipfs-mini icon indicating copy to clipboard operation
ipfs-mini copied to clipboard

fix hashes in examples

Open slothbag opened this issue 7 years ago • 2 comments

slothbag avatar Dec 13 '17 03:12 slothbag

Coverage Status

Coverage remained the same at 100.0% when pulling 62bef57e52bade8d71d301fe3e18c4b22454591d on slothbag:master into 4bf0d7e5cc473933c8b83dc4395c93caf56c2be9 on SilentCicero:master.

coveralls avatar Dec 13 '17 03:12 coveralls

I came here to say this but the code comments should be fixed too, also you shouldn't fetch the results synchronously when the put hasn't completed yet, more like this:

import IPFS from 'ipfs-mini'

const ipfs = new IPFS({ 
  host: 'localhost',
  port: 5001,
  protocol: 'http'
});
 
ipfs.add('hello world!', (err, result) => {
  // result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'
  console.log(err, result);

  ipfs.cat('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', (err, result) => {
    // result null 'hello world!'
    console.log(err, result);
  });
});

ipfs.addJSON({ somevalue: 2, name: 'Nick' }, (err, result) => {
  // result null 'QmYzWWCvYhqU6d5VvRvVwgbpqM9J3HH8TMbns9UvFSSvBf'
  console.log(err, result);

  ipfs.catJSON('QmYzWWCvYhqU6d5VvRvVwgbpqM9J3HH8TMbns9UvFSSvBf', (err, result) => {
    // result null, { somevalue: 2, name: 'Nick' }
    console.log(err, result);
  });
});

Also, I had to switch to http.

justinmchase avatar Oct 13 '18 14:10 justinmchase