How to make await calls in init()
?
#4410
-
I've tried Googling this for a while and attempting a few different things, but nothing seems to work. I have some The things I can remember trying for this are:
Nothing seems to work, so I'm not sure if I'm doing this wrong or if it's just not possible. If it's not, then how can I resolve the promises without suffering from callback hell? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Can you share the code to show what you are trying to do. Init functions support await but I suspect you mean something else (like you want other directives to wait for init)? Simple example of await in x-init: https://codepen.io/SimoTod/pen/jOgLjqp |
Beta Was this translation helpful? Give feedback.
-
just making init async works fine. |
Beta Was this translation helpful? Give feedback.
That would give me the same error.
x-data
isn't failing to evaluate for me, but I'm also using Livewire/Laravel@js()
to transform data, which may be why it fails for you.I did get it working though, with this being the final result: