samedi 10 mars 2018

VueJS function reutrn not working

I've a little problem with my vuejs global function. I created this global function in my app.js

export function getSession(key) {
  $.post('/api/session', function (result) {
    if (result.hasOwnProperty(key)) {
        return result[key];
    }
  });
}

If i echo the return of this function in a vue component at the mounted() part the console tells me undefined. But if i replace line 4 with console.log(result[key]) I get the right value.

Why is this so. Please help!



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2p4w4VU
via IFTTT

Aucun commentaire:

Enregistrer un commentaire