bitaps-com / wallet-api-examples

Wallet API examples
6 stars 5 forks source link

ERROR 304 #2

Closed HackinwaleDev closed 5 years ago

HackinwaleDev commented 5 years ago

I am not getting any response while trying to create wallet. Does it mean this API does not support NodeJs or what was I doing wrong?

4tochka commented 5 years ago

Could you provide more details ?

HackinwaleDev commented 5 years ago

Sure! Below is my implementation around the endpoint given to me:

const request = require('request'); const BASE_URI = "https://api.bitaps.com/btc/testnet/v1/";

Creating module (bitaps_com.js)

module.exports = { // Let's create the wallet createAdminWallet: (walletCallbackUri) => { let options = {callback_link: walletCallbackUri, password: "mypassword"} return new Promise(() => { request.post(BASE_URI+"/create/wallet", options); }); } }

@4tochka

Using the module (index.js)

const bitaps = require('../bitaps_com'); const {createAdminWallet} = bitaps;

let callbackUrl = 'http://myhostname/wallet/report' createAdminWallet(callbackUrl) .then(response =>{ console.log('=========Wallet Created Successfully=======') console.log(response.wallet_id +' --- '+ response.currency); }) .catch(err => { console.log('========Failed to create wallet=========='); console.log(err); });

Pls kindly check and see what I am doing wrong. thanks.

HackinwaleDev commented 5 years ago

Fixed now. I was wrapping request.post in Promise whereas it is a promise itself.

_return request.post((BASEURI+"/create/wallet", options); is the right way

Thanks.