#Data discrenpancy in querying

1 messages · Page 1 of 1 (latest)

meager acorn
#

Hey guys,

So on the picture you can see that I have a query called GetPolicyHolder.

And when I ran it and console.log the data After the query I got
"Father" as one of the Tags.

So in this query appsmith only got one data which is Father

But on the second picture when I ran the query manually you can see that there is loads of data after Father like Testing, Phone_Only, 2-Sons.

Also the datasource is synced up with the Query from the sheets but not from the JS Object.

The JS Object only has "Father"

TL;DR
The query form js object is different than with normal query

wild wraithBOT
#

Hey There,

We've registered your query, and our team will get back to you soon.

Regards,
Pranav

#

Hey there!
So, a better way I can suggest you run this query is to use async/await.

const results = await GetPolicyHolder.run();
for(const result of results) {
// Go ahead and do what you want with individual result
}

Can you try this approach and see if it works for you?

meager acorn
#

but yeah this works, why does using promise doesnt?

wild wraithBOT
#

Using promise works. In the case of your code, however, on line 22, you called
GetPolicyHolder.data. This particular reference will first call your query and
then return the data. This way, there's no guarantee that the data gets returned
before you started looping through it.

That's why it's always safe to await query/API responses within your JsObjects
before proceeding to use them.