Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
11379 Vues

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
Ignorer
Meilleure réponse

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
Ignorer

For me it's works!

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

Publications associées Réponses Vues Activité
1
juil. 20
6603
0
juil. 25
430
1
juil. 25
5359
0
juil. 25
908
0
juin 25
911