Skip to content

Instantly share code, notes, and snippets.

@carsonfarmer
Last active November 26, 2018 05:37
Show Gist options
  • Save carsonfarmer/29cac2815b419d82d109d8fc98e1ca81 to your computer and use it in GitHub Desktop.
Save carsonfarmer/29cac2815b419d82d109d8fc98e1ca81 to your computer and use it in GitHub Desktop.
Initial app code
/* eslint no-undef: "error" */
/* eslint-env browser */
import 'babel-polyfill'
import getIpfs from './ipfs-promise'
import qs from 'query-string'
// setup is our async initializer function
const setup = async () => {
try {
// Get a reference to the running, or new, IPFS peer/node
const ipfs = await getIpfs()
// Grab query string to check who's profile we're viewing
const query = qs.parse(location.search)
// Grab id of this IPFS peer, to check if we're viewing our own profile
const id = await ipfs.id()
// user id that we will use to request profile information
const user = query.user ? query.user : id.id
// Some reporting to help us when developing
console.log(`Viewing profile for ${user} from peer with id ${id.id}`)
if (user === id.id) {
console.log(`Viewing own profile, editing will be enabled!`)
}
} catch (err) {
console.log(err)
}
}
setup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment