Displaying content out of two Datasets

Hey! I have a problem with my code, and after days of searching and trying I found out, that I might use Promises. But tbh, I don’t really get how to add promises to my code.

So, I wanted to create a picture database for Organs for a colleague. On home I have different rubrics, like “Our Favorites” or “Newest”. If you click on the picture you get redirected to a preset page using the ID of the “Uploaded Pictures Dataset” and you are going to see the picture in higher resolution. Now, I’d like to query a second Dataset called “Organ Dataset”, where all the details to the organ are located, like Location, Organ Builder and so on.
To make it easy for my coding skills (this may be a mistake…) I added a field to the “Uploaded Pictures Dataset” called “organid” where I put the ID of the second dataset (Organ Dataset) in. Because, as you may think, there are more pictures to one organ but there are not more organs to one Picture. I attached the code of the “Preset Page” here:

let query = wixLocation. query;

wixData.query("UploadedPictures Dataset")
  .eq("_id", query. id)
  .find()
  .then( (results) => {
    if(results. items. length > 0) {
      let items = results. items;
      let firstItem = items[0];
      let mode = $w("#image2"). fitMode = "fixedWidth";
      console.log(firstItem.UploadedPictures);
      $w('#text38'). text = firstItem. organid;
      $w('#image2'). src = firstItem. image;
      $w('#text18'). text = firstItem. photographer;
    } else {
      console. log("No Item found. - 1");
    }
  } )

wixData. query("Organs Dataset")
  .eq("organid", query. _id)
  .find()
  .then( (results) => {
    if(results. items. length > 0) {
      let items = results. items;
      let secItem= items[0];
      console.log("_id");
      $w('#text19'). text = secItem. type; //Organ type
      $w("#text11"). text = secItem. title; //Name of the organ
      $w("#text12"). text = secItem. location; //Location of organ
      $w('#text28'). text = secItem. builder; // Organ builder
      $w("#text25"). text = secItem. manuals; //Number of manuals
      $w("#text26"). text = secItem. stops; //Number of stops
      $w('#text29'). text = secItem. constructionyear;
      $w('#text30'). text = secItem. disp1; //disposition manual 1
      $w('#text31'). text = secItem. disp2; //disposition manual 2
      $w('#text32'). text = secItem. disp3; //and so on...
      $w('#text33'). text = secItem. disp4;
      $w('#text34'). text = secItem. disp5;
      $w('#text35'). text = secItem. disp6;

    } else {
       console. log("No Item found. - 2");
    }
  } )

console. log("after");

Can someone help me on this page please? My coding skills are right at the edge here :sweat_smile:

Thanks in advance!

Mike