Onyx-Protocol / Onyx

Onyx

Home Page:https://Onyx.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unhandled Promise Rejection Warning: Request could not be authenticated

AzizGayes opened this issue · comments

Hello guys,

Environment

  1. Chain Core Version: 1.2.0
  2. Chain Core SDK Language and Version: Javascript: 1.2.0-rc.2
  3. Host: Docker (on ubuntu)

What steps will reproduce the problem?

const chain = require('chain-sdk');
const client = new chain.Client();
const keyPromise = client.mockHsm.keys.create();

What result did you expect?

Getting a valid key.

What result did you observe?

(node:4687) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Code: CH009 Message: Request could not be authenticated Request-ID: a21c94d7a7d656e505d7

Can someone help me? please?

Hi Aziz,

It looks like you may need to configure your Chain client so it knows how to reach your Docker-hosted Chain Core:

const client = new chain.Client(
  url: "http://localhost:<port-to-docker-image>"
  accessToken: ... // This appears when you launch the docker image for the first time
);

Also, since mockHsm.keys.create can produce errors, you need to handle them or else you'll get UnhandledPromiseRejectionWarning:

client.mockHsm.keys.create().then(key => ...).catch(err => ...);

Hi @AzizGayes, I'm gonna go ahead and close this issue. If you have any more questions, feel free to reach out to us at our tech support chatroom at https://chain.slack.com.