Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
n3xus34407y@practiseSafeHex yeah promises are great but I'm not sure how to incorporate it especially with dynamic nested JSON objects.
-
Froot75547y@n3xus What is a dynamic nested json object?
Also, why don't you want node to be async? That's the main benefit of node!
Anyhow, look into request.js and express.js, either if you want to send a request or receive one. What you're doing can probablly be done with those in like 10 lines of code -
n3xus34407y@Froot alright let me explain a little bit, basically this makes multiple requests to mining pools, these pools are stored in a JSON like so: https://coinstop.me/config/... . I need to make a request to each url in that JSON and make one big JSON of the requests.
If you are wondering where the API endpoint is its at /index.php?page=API&action=public . -
Froot75547y@n3xus Cool.
Map over the object and return a promise for each request. Then wrap those promises in a Promise.all and do your thing once that one resolves. If you need rate limiting then npm is full of packages for that.
I made one of them but linking it here would connect my devrant name to the real me and that's a big no no. -
n3xus34407y@Froot haha alright thanks for the help! You saved me a headache and possibly a cup of coffee (only possibly). :)
-
Froot75547y@n3xus but coffee is good π
I hope you can figure it out. Stick at it, you'll love it once you realise the power of node.js βΊοΈ -
When something piss you off a lot, think you are neither the only one nor the first one. Most of the times there's a better way to do the things.
-
@wiredgecko Promise.all runs promises concurrently and returns when then have all finished
-
@practiseSafeHex thanks, I sort of knew that although I commented before I reached that earlier comment about using Promise.all
-
dotio2297y@n3xus Ever heard of async/await package??
https://github.com/yortus/...
You can't blame it just like that!π -
I had this problem, I solved it with async/await and a function that replace callbacks with promises.
-
joegalaxy447yGolang is my language of choice. I still Need to maintain and write PHP (ugh) and node. But when I Can, I prefer go. Working on a huge piece of code left alone for more that a year and understand everything again after 5 minutes looking at It is just great. Nice feeling.
Related Rants
Fuck NodeJS. I don't want you to be asynchronous sometimes. My gahwd I need like 3 deep nested loops just to get you to make a request and compile a damn JSON of requests.
I'm learning Golang goodbye forever node.
rant
callback
callback hell
async
async hell
nodejs
asynchronous
golang