retrieve data from dataset and use them in the code

Hello…i was tryin to retrieve the field values of one dataset with that code:
$w( “#dataset1” ).onReady( () => {
$w( “#dataset1” ).getItems( 1 , 1 )
.then((result) => {
let item = result.items.cleanJerk;
let totalCount = result.totalCount;
let offset = result.offset;
console.log(item)
$w( ‘#text183’ ).text = JSON.stringify(item)
} )
. catch ( (err) => {
let errMsg = err.message;
let errCode = err.code;
});

but that shown only UNDEFINED

If I use this
let item = result.items;
I get the following object, how can i retrieve one of the above field?

cleanJerk: 130
weight: 76
benchPress: 100
email: “d.zibra@yahoo.it”
_id: “10544d32-f484-47f0-aa55-1fe052227744”
_owner: “10544d32-f484-47f0-aa55-1fe052227744”

thank you in advance
@russian-dima

let item = result.items; 
let weight = result.items.weight; console.log(weight)
let ID = result.items._id; console.log(ID)
let OWNER = result.items._owner; console.log(OWNER)
let EMAIL = result.items.email; console.log()

Add this code-parts to your CODE and take a look onto CONSOLE after running your code.

thank you @russian-dima …unfortunately in the console is shown UNDEFINED…

Can you show the console-screenshot?
Which console do you use?

yes

yes @russian-dima

This screenshots do not really help.
Try to debug it by your own.
You told in your last post that you get the following results…

I get the following object, how can i retrieve one of the above field?
cleanJerk: 130
weight: 76
benchPress: 100
email: “d.zibra@yahoo.it”
_id: “10544d32-f484-47f0-aa55-1fe052227744”
_owner: “10544d32-f484-47f0-aa55-1fe052227744”

You now should take a look onto the structure of this object in the console (use the console of Google-Chrome.)

Once you have the results in front of your eyes, take a look how it is structured.

When this here did not work for you…

let weight = result.items.weight; console.log(weight)
letID= result.items._id; console.log(ID)
letOWNER= result.items._owner;console.log(OWNER)
letEMAIL= result.items.email; console.log()

Perhaps this one will work…

let weight = result.items[0].weight; console.log(weight)
let ID= result.items[0]._id; console.log(ID)
let OWNER= result.items[0]._owner; console.log(OWNER)
let EMAIL= result.items[0].email; console.log(EMAIL)
1 Like

I Tried some values and seems to work…
thank you very very very much @russian-dima !!!
in the next days I will finish the page where i am working and see if there is any other problem.
you saved my website

No problem. :wink: