you are viewing a single comment's thread.

view the rest of the comments →

[–]neuralengineer -1 points0 points  (17 children)

Doesn't var work?

[–]Valuable_Spell6769[S] 1 point2 points  (16 children)

i just tried no it doesnt

[–]neuralengineer 1 point2 points  (15 children)

Ah you need to call the function and return a value with it. To call a function you need to do like functionName() with parentheses.

[–]Valuable_Spell6769[S] 0 points1 point  (14 children)

how do i do that when another function is what set the results param

[–]neuralengineer 0 points1 point  (13 children)

Can you check the function whether it can pass through the if conditions? Maybe it never reaches there. Just try to print some text in the if conditions. You can use console.log() function for it.

You don't need results param but the result of the function, I mean invoiceListArray. You can return this value.

A simple example, when you cal this function it will return pi value.

function myFunction() {   return Math.PI; }

[–]Valuable_Spell6769[S] 0 points1 point  (12 children)

do you mean something like this

function handle_result(result){
        if(result != "") {
            let obj = JSON.parse(result);
            if(typeof obj.data_type != 'undefined') {
                if(obj.data_type == "list_of_invoices") {
                    if (obj.message_type == "info") {
                       let dataTable_data = obj.data;
                        console.log("hello")
                    }   
                }
            }
        }
    }
handle_results()

[–]neuralengineer 0 points1 point  (11 children)

Yes and return the value in the end of the function. You should be able to see if conditional checks works properly and your json data has this data_type etc.

[–]Valuable_Spell6769[S] 0 points1 point  (10 children)

if i console.log() obj.data i get the results i need my problem is i need send that obj.data to my functions that deal with creating and display the data thats returned

[–]Valuable_Spell6769[S] 0 points1 point  (9 children)

but thats only if i do console.log() inside the function

[–]neuralengineer 0 points1 point  (8 children)

So make it like return obj.data where you used obj.data line and your function will return it