js-bigchaindb-driver
js-bigchaindb-driver copied to clipboard
how to emit '403 Forbidden' to UI
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' }
You can use:
conn.postTransactionCommit(createTranfer)
.then(res => {
//...
})
.catch(err => {
if(err.status == '403 Forbidden')
})
See also #169
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)
});