Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
11225 Visninger

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
Kassér
Bedste svar

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
Kassér

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 Besvarelser Visninger Aktivitet
1
jul. 20
6494
0
jul. 25
270
1
jul. 25
5043
0
jul. 25
607
0
jun. 25
689