İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
11228 Görünümler

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
Vazgeç
En İyi Yanıt

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
Vazgeç

For me it's works!

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

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Tem 20
6500
0
Tem 25
280
1
Tem 25
5050
0
Tem 25
612
0
Haz 25
694