11
n3xus
7y

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.

Comments
  • 3
    You should try promises. They really helped me cut my nesting down
  • 0
    @practiseSafeHex yeah promises are great but I'm not sure how to incorporate it especially with dynamic nested JSON objects.
  • 2
    @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
  • 0
    @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 .
  • 3
    @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.
  • 0
    @Froot haha alright thanks for the help! You saved me a headache and possibly a cup of coffee (only possibly). :)
  • 2
    @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 ☺️
  • 0
    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.
  • 0
    And if you run concurrent promises?
  • 0
    @wiredgecko Promise.all runs promises concurrently and returns when then have all finished
  • 0
    @practiseSafeHex thanks, I sort of knew that although I commented before I reached that earlier comment about using Promise.all
  • 1
    @n3xus Ever heard of async/await package??
    https://github.com/yortus/...
    You can't blame it just like that!😏
  • 1
    I had this problem, I solved it with async/await and a function that replace callbacks with promises.
  • 1
    Golang 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.
  • 1
    Go for it ;)
Add Comment