Get http-function wirt referended fields

Hi, I’m trying a get-method in order to get data from one of my collections. I have problems when I want to join the main collection to another one in in order to get more information of a referenced field.

After trying different options, this is now my code:

export async function get_allPosts(request) {
let response = {“headers”: {“Content-Type”: “application/json”}};
var a = [];

a = await wixData.query("posts") 
	.find() 
	.then((results) => { 
		return results.items; 
	}); 

await a.forEach(function(element){ 
	wixData.get("members", element.admin) 
	.then((results) => { 
		element.admin = results.adminemail; 
	}); 
	
}); 


response.body = {"items": a}; 
return ok(response); 

}

Result:

  • it’s returning de results from “posts” but with the “adminid” instead of “adminemail”.

  • I have no problemas when I wanna have this information in a “normal way” (not in http-function)

Any help, please?!