Open slothbag opened 6 years ago
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.
Coverage remained the same at 100.0% when pulling 62bef57e52bade8d71d301fe3e18c4b22454591d on slothbag:master into 4bf0d7e5cc473933c8b83dc4395c93caf56c2be9 on SilentCicero:master.