Get data from Data Collection

Hi,

I want to get data from a Data Collection using Wix Code… I tried the following code:

$w(“#infocredits”).text = "Credits: " & wixData.get(“CrateDatabase”, “credits”);

But it always gives me and error. I know just the basics, so can someone help me please?

1 Like

Look in the API for samples:

Here is one:

import wixData from 'wix-data'; // ...  
wixData.query("YOUR DATA COLLECTIONS NAME") 
.find() 
.then( (results) => { 
  let firstItem = results.items[0];
  $w("#infocredits").text = "Credits: " + firstItem.fieldKeyName // fieldKeyName is the fields keyname in you collection
} ) 
.catch( (err) => { 
  let errorMsg = err; 
} );

Find more at: