Last active
November 26, 2018 05:37
-
-
Save carsonfarmer/29cac2815b419d82d109d8fc98e1ca81 to your computer and use it in GitHub Desktop.
Initial app code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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