Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Nondescript error when using get/set functions #31

Open
koffisam opened this issue Jun 29, 2017 · 11 comments
Open

Nondescript error when using get/set functions #31

koffisam opened this issue Jun 29, 2017 · 11 comments

Comments

@koffisam
Copy link

Hi,
I am building an application that uses uport and registry, while setting or getting key/value pairs on the registry I keep getting this error

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): ReferenceError: document is not defined

Any help is greatly appreciated.

@oed
Copy link
Contributor

oed commented Jun 30, 2017

Hey,
Could you provide the code you have to replicate this error?

@koffisam
Copy link
Author

koffisam commented Jun 30, 2017

	var web3 = uport.getWeb3()

Registry.setProvider(web3.currentProvider)

var registry;

Registry.deployed().then(function(instance) {
   registry = instance;
  
});
//
//much later
//
        var daddr = mnid.decode(req.body.addr)
	var addr=daddr.address;
	var hash="someValue";
	let key = "myKey"    

	console.log(daddr);
	console.log(registry);

	let subject =  addr
                      
	let value = hash;
                      
registry.set(key, subject, value);

@oed
Copy link
Contributor

oed commented Jul 3, 2017

Hm, I have no problem with that. Did you import the registry this way?

const regsitryArtifact = require('uport-registry')
const Contract = require('truffle-contract')
const Registry = Contract(regsitryArtifact)

@koffisam
Copy link
Author

const regsitryArtifact = require('uport-registry')
const Contract = require('truffle-contract')
var mnid = require('mnid')
var Registry = Contract(regsitryArtifact)

This is how I'm importing it

@oed
Copy link
Contributor

oed commented Jul 10, 2017

That's strange. However I'm unable to reproduce this error.
Is it the call to registry.set(key, subject, value); that gives you the promise rejection?

@koffisam
Copy link
Author

koffisam commented Jul 10, 2017 via email

@koffisam
Copy link
Author

I am running this code on my node-js server, not in the frontend like the uport-connect example. It just occurred to me that this might be the cause. Can you confirm?

@oed
Copy link
Contributor

oed commented Jul 11, 2017

Ok, so what library are you using for doing uport.getWeb3()?

@koffisam
Copy link
Author

const uportCon = require('uport-connect');

const uport = new uportCon.Connect('MyDApp')

var web3 = uport.getWeb3()

@oed
Copy link
Contributor

oed commented Jul 18, 2017

Oh, right. uport-connect is only intended to be used in the browser and not in a node server. Take a look at uport-lite and uport-js.

@oed
Copy link
Contributor

oed commented Nov 13, 2017

@koffisam this seems to be the same issue as #38 can you try out the solution I posted there?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants