Skip to content

Instantly share code, notes, and snippets.

@makoto
Last active February 10, 2019 10:08
Show Gist options
  • Save makoto/d2b64de28ad85e084612d7101cd166a8 to your computer and use it in GitHub Desktop.
Save makoto/d2b64de28ad85e084612d7101cd166a8 to your computer and use it in GitHub Desktop.
makoto@Makotos-MacBook-Air: [~/src/tmp/univesal - (master)] $ more package.json
{
"name": "univesal",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start:dev": "universal-login start:dev"
},
"keywords": [],
"license": "ISC",
"resolutions": {
"web3": "1.0.0-beta.35"
},
"dependencies": {
"truffle": "^5.0.3",
"universal-login-sdk": "^0.1.9"
},
"devDependencies": {
"universal-login-ops": "^0.1.6"
}
}
makoto@Makotos-MacBook-Air: [~/src/tmp/univesal - (master)] $ more index.js
var UniversalLoginSDK = require('universal-login-sdk').default;
const universalLoginSDK = new UniversalLoginSDK('http://localhost::3311', 'http://localhost:18545');
var privateKey;
var contractAddress;
console.log({privateKey,contractAddress});
universalLoginSDK.create('myname.example-domain.eth').then((a,b,c)=>{
console.log({a,b,c})
privateKey =a; contractAddress=b;
console.log({privateKey,contractAddress});
})
makoto@Makotos-MacBook-Air: [~/src/tmp/univesal - (master)] $ node index.js
{ privateKey: undefined, contractAddress: undefined }
(node:24545) UnhandledPromiseRejectionWarning: FetchError: invalid json response body at http://localhost:3311/:/identity reason: Unexpected token < in JSON at position 0
at /Users/makoto/src/tmp/univesal/node_modules/universal-login-sdk/node_modules/node-fetch/lib/index.js:241:32
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:24545) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:24545) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@marekkirejczyk
Copy link

Fixed version:

var  UniversalLoginSDK = require('universal-login-sdk').default;
const universalLoginSDK = new UniversalLoginSDK('http://localhost:3311', 'http://localhost:18545');

var privateKey;
var contractAddress;
console.log({privateKey,contractAddress});
universalLoginSDK.create('duwpa.mylogin.eth').then(([privateKey, contractAddress])=>{
    console.log({privateKey,contractAddress});
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment