Skip to content
Discussion options

You must be logged in to vote

<div x-data="yourFunction" x-init="foo = await bar()">...</div>

<script>
function yourFunction() {
  return {
    foo: [], //default to empty array
    async bar() {
      ... //your fetch
   } 
}
</script>

For example.

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@SimoTod
Comment options

SimoTod Dec 9, 2021
Collaborator

Answer selected by bubnenkoff
Comment options

You must be logged in to vote
2 replies
@SimoTod
Comment options

SimoTod Dec 9, 2021
Collaborator

@bubnenkoff
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants