[Vuejs]-Stripe promise pending even though it's async/await

0👍

let session = obtainSession(this.session_id)
         .then(session=> {
           return session
         });

Doing this doesn’t mean this will return after the then– it will return immediately with the Promise returned by obtainSession. The continuation will also run once the promise resolves, but that return is basically meaningless in this flow.

You will have to await this call. Or if you log inside the then you’ll see the result.

You could consider retrieving this and awaiting inside mounted or similar, or have the code set session as a module variable. But in all cases this is going to be something that returns a promise you have to wait for outside of tHat assignment.

Leave a comment