Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
11268 Переглядів

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

Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити

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 Відповіді Переглядів Дія
1
лип. 20
6535
0
лип. 25
321
1
лип. 25
5124
0
лип. 25
684
0
черв. 25
740