Asynchronous request on blockchain

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@cedric-g·
0.000 HBD
Asynchronous request on blockchain
Hi everyone!

I’m currently developing a website using Express.js to list challenges we can find on steemit. I was facing a bug when I was requesting the blockchain. 

My error was a timeout every time I was trying to request the blockchain for the second time. The first request was always working but the second one always gave me this « Timeout Error » and I had to restart my server every time to be able to request again the blockchain.

I tried everything and I finally found my answer thanks to @codingdefined. 

[Here is the link to @codingdefined ’s post where i found the solution](https://steemit.com/utopian-io/@codingdefined/using-asynchronous-function-when-voting-using-steem-js
)

As @codingdefined explain in his post, we need to use another URL to request the blockchain with asynchronous functions. 

Here are the commands to change the URL you will use :

// Steem var
const steem = require('steem');
steem.api.setOptions({url: 'https://api.steemit.com'}); 

Using that helped me to get rid of the timeout error.

Hope that’s gonna help you guys.

@cedric-g

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@cedric-g/asynchronous-request-on-blockchain">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍 , , ,