I am working with Esri ArcMap APIs and I made a function that makes query the layer and returns the result, I want to make this function return the result to use it in making widgets.
function queryLayer(filterType,value){
var x
schoolLayer.definitionExpression = filterType+" = '" + value + "'";
const queryParams = schoolLayer.createQuery();
queryParams.where = filterType +" = '" + value + "'";
queryParams.outFields = [filterType]
schoolLayer.queryFeatures(queryParams).then(function (results) {
x = results.features
});
return x
}