Skip to content

Instantly share code, notes, and snippets.

@carsonfarmer
Created June 14, 2018 06:42
Show Gist options
  • Save carsonfarmer/cfb1618e7f8bb46460b6c6f658e509fc to your computer and use it in GitHub Desktop.
Save carsonfarmer/cfb1618e7f8bb46460b6c6f658e509fc to your computer and use it in GitHub Desktop.
main.js step 2
import 'babel-polyfill' // We need this for async/await polyfills
// Import our two IPFS-based modules
import getIpfs from 'window.ipfs-fallback'
import crypto from 'libp2p-crypto'
let ipfs
// Setup a very simple async setup function to run on page load
const setup = async () => {
try {
ipfs = await getIpfs() // Init an IPFS peer node
const id = await ipfs.id() // Get the peer id info
console.log(`running ${id.agentVersion} with ID ${id.id}`)
} catch(err) {
console.log(err) // Just pass along the error
}
}
setup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment