コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
11192 ビュー

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
6477
0
7月 25
227
1
7月 25
4983
0
7月 25
526
0
6月 25
628