How do I apply the async/await feature to this code? I need to wait for the reltionshipQuery and forEach to finish before I return contentSpecies.
contentSpecies = function(value, key, data) {
var contentSpecies = [];
objectID = data.OBJECTID;
var queryTask = new QueryTask({
url: "https://webmaps.com/MapServer/1"
});
var relationQuery = new RelationshipQuery({
objectIds: [objectID],
outFields: ["Species", "Notes", "Status"],
returnGeometry: true,
relationshipId: 0
});
queryTask.executeRelationshipQuery(relationQuery)
.then(function(rslts) {
var features = rslts[objectID].features;
features.forEach(function(ftr) {
var t = ftr.attributes;
var species = t.Species;
contentSpecies += "<span class='bold' title='Species'><b>Species: </b></span>" + species + "<br/>";
var notes = t.Notes;
contentSpecies += "<span class='bold' title='Notese'><b>Notes: </b></span>" + notes + "<br/>";
var status = t.Status;
contentSpecies += "<span class='bold' title='Status'><b>Status: </b></span>" + status + "<br/>";
});
//return contentSpecies;
})
return contentSpecies
}