Promisify js-ipfs

I recently tried out js-ipfs, but the api was a bit unintuative to use.
Maybe making js-ipfs a promised based modules would be better, or maybe there’s a reason to why it’s not promised based?

Can you post a example of what you are trying to do and where it’s going wrong? js-ipfs should already support both callbacks and promises.

The following calls are doing the same things:

// Callback API
ipfs.files.add(file, (err, res) => {
  if (err) throw err
  console.log(res)
})
// Promise API
ipfs.files.add(file).then((res) => {
  console.log(res)
}).catch((err) => {
  throw err
})
1 Like