Skip to content

How to make await calls in init()? #4410

Discussion options

You must be logged in to vote

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:

<div
    x-data="{
        map,
        markers: [{
            lat: @js($location->latitude()),
            lng: @js($location->longitude()),
        }],
        markerHandler,
        placeMarkers () {
            // console.log(this.markerHandler);
        },
        init: async function () {
            let m;
            let bounds;
            let mapEl = this.$refs.map;

            let center = { ...this.markers[0] };

            const { Map } = awa…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@eric-hansen
Comment options

Comment options

You must be logged in to vote
5 replies
@eric-hansen
Comment options

@eric-hansen
Comment options

@ekwoka
Comment options

@eric-hansen
Comment options

Answer selected by eric-hansen
@ekwoka
Comment options

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