I have been adding custom functionality in Strapi code through the controller. The below result variable comes up as undefined. If I return the result variable directly in the function the result is correctly returned in the http response. Is there any issues in the syntax below ? I appreciate any help i can get.
'use strict';
/**
* Read the documentation (https://strapi.io/documentation/3.0.0-beta.x/concepts/controllers.html#core-controllers)
* to customize this controller
*/
module.exports = {
async getItemAggregate (context) {
var itemid = context.params.itemid
strapi.log.info(itemid)
strapi.log.info("test aggregate");
const result = await strapi.query('aggregate').findOne({"id": itemid});
strapi.log.info(result)
// const fields = result.toObject();
// strapi.log.info(result)
// entities = await strapi.services.aggregate.search({"id":1});
// entities2 = await strapi.services.item.search({"id":1});
// strapi.log.info(entities)
strapi.log.info(result)
// strapi.log.info(entities2)
//get latest aggregate
//get latest tranacitons
}
};