✅ – ✅ – beautifulpython – 19-38 Jul 25
greetings, I have a self referencing async function that populates a global array declared top of my code
let final = []
But when I try to see it's value it still shows as []. Here is my code been at it for almost 4 hours and stuck36 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yes sir
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
this is for trino database and when using rest api youknow it has ended or drained when
d.nextUri
is not longer thereUnknown User•2y ago
Message Not Public
Sign In & Join Server To View
do I need some type of event listener for this
onEnd
?Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ok let me read up on that how to implement sucj a thing. thnx!
can this work?
oh wait it has to be passed on got it
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
anonymous function no name
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
i cant bcs its anonymous
i need to naem it
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
oh sorry. i was going to dump it here
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
when it is
done
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
onEnd is not a function
let me read up on this some more. thanks!Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Or you could just await the drainTrino call inside the function
And merge what it returns with orders
And return that
ok let me try both. brb lunch time
yes some init stuff does call it indeed.
looking great @slightlytyler ! thanks
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ok, part of learning so this gets me closer to the polished version of @ghardin137
@ghardin137 liek this?
await drainTrino(d.nextUri)
Yeah but you need to get accept the return value
Then merge that with the other orders
And return that
ok, let me give that a spin
I think I am stuck so I will hand this over to a more experiences dev
something like that should work
you don't need the external orders variable
thanks you so much
the reason I needed orders as global is I need to return it to my calling app. in this case grafana
you can still do that
it's the returned value of the drainTrino function 🙂
technically you don't even need that first bit
that would work exactly the same 🙂
duh! you are right
yup recursion can sometimes be pretty awesome
"sometimes" is the key word. inception movie comes to mind
😆
oh yes
it can also be a complete nightmare
looks like there is an issue in the else part. no worries I will run with it you have guided me enough. thanks!
thanks so much @ghardin137 learned a lot. final product is here
the first drain call requires a
POST
instead of a GET
This question has an answer! Thank you for helping 😄
If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1133483358408687657
This question has an answer! Thank you for helping 😄
If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1133483358408687657
This thread hasn’t had any activity in 36 hours, so it’s now locked.
Threads are closed automatically after 36 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1133483358408687657