Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
11193 Zobrazení

I try to get data from odoo server using js, but I have a problem when I print this data I get undefined how I can solve this problem I want to get this data outside .then

        var ajax = require('web.ajax');
        var result;
        ajax.jsonRpc("/get_data", 'call', {}, {
            'async': false
        }).then(function (data) {
            result = data;
        });
        console.log(result); // undefined

Avatar
Zrušit
Nejlepší odpověď

Hi,

Can you try the code like below

var ajax = require('web.ajax');
var result = [];
ajax.jsonRpc("/get_data", 'call', {}, {
'async': false
}).then(function (data) {
result.push(data);
});
console.log(result)

Regards

Avatar
Zrušit

For me it's works!

i have added return result ; statement at last it is returning empty array..how can return that value?

Related Posts Odpovědi Zobrazení Aktivita
1
čvc 20
6477
0
čvc 25
228
1
čvc 25
4986
0
čvc 25
527
0
čvn 25
631