Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to emit '403 Forbidden' to UI #249

Open
srinivasyl opened this issue Sep 11, 2018 · 2 comments
Open

how to emit '403 Forbidden' to UI #249

srinivasyl opened this issue Sep 11, 2018 · 2 comments

Comments

@srinivasyl
Copy link

srinivasyl commented Sep 11, 2018

var driver = require('bigchaindb-driver')

var alice = new driver.Ed25519Keypair()
var conn = new driver.Connection(
    'https://test.bigchaindb.com/api/v1/',
    { app_id: 'my_app_id',
      app_key: 'wrong key' })

var tx = driver.Transaction.makeCreateTransaction(
    { city: 'Bangalore', temperature: 22, location:'Winjit Bangalore', datetime: new Date().toString() },
    null,
    [ driver.Transaction.makeOutput(
        driver.Transaction.makeEd25519Condition(alice.publicKey))],
    alice.publicKey)

var txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)

conn.postTransactionCommit(txSigned).then(function(retrievedTx){
		if(retrievedTx){
			console.log('Transaction', retrievedTx.id, 'successfully posted.')	
		}
});

if wrong API key is given it gives below erro how to emit this to UI
what condition should i check to this error

{ message: 'HTTP Error: Requested page not reachable', status: '403 Forbidden', requestURI: 'https://test.bigchaindb.com/api/v1/transactions?mode=commit' }

@future-is-present
Copy link
Contributor

You can use:

      conn.postTransactionCommit(createTranfer)
        .then(res => {
            //...
        })
        .catch(err => {
           if(err.status == '403 Forbidden')
        })

See also #169

@srinivasyl
Copy link
Author

srinivasyl commented Sep 17, 2018

Thank you
it got sorted i used

conn.postTransactionCommit(txSigned).then(function(retrievedTx){
			console.log('Transaction', retrievedTx.id, 'successfully posted.')	
},function(err){
	console.log(err)
});

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

No branches or pull requests

2 participants