跳至內容
選單
此問題已被標幟
1 回覆
11200 瀏覽次數

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?

相關帖文 回覆 瀏覽次數 活動
1
7月 20
6479
0
7月 25
247
1
7月 25
5004
0
7月 25
555
0
6月 25
648