Return from Async Function

I have a code that looks like this:

await createPackage(oderSummary);
async function createPackage(oderSummary) {
  let pickPosition = true;
  let lineItemsArr = [];
  const r = Object.keys(oderSummary[0]).map((v) => ({
    [v]: => c[v]),
  let tableItem = [...r[2]["Pozycja"]];
  while (pickPosition == true) {
    let pickItem = await input.buttonsAsync(
      "Pick order to pass",
    let filteredOrders = oderSummary.filter(
      (item) => item.Pozycja !== Number(pickItem)
    let difference = oderSummary.filter((x) => !filteredOrders.includes(x));
    tableItem = tableItem.filter((v) => String(v) !== pickItem);
    oderSummary = filteredOrders;
    if (pozycjaTabeli.length) {
      let shouldContinue = await input.buttonsAsync("Dodac Nastepna?", [
        { label: "Yes", value: "Yes" },
        { label: "Cancel", value: "Cancel", variant: "danger" },
      if (shouldContinue == "Yes") {
        foo(oderSummary, "RecordID");
      } else {
        pickPosition = false;
    } else {
      pickPosition = false;
  return lineItemsArr;

How to can I rewrite the createPackage function to return the value of lineItemsArr?

Can you provide some more details?
It looks like the function already returns lineItemsArr.
However, you do not include enough of the code to see where this variable is set or what value it should have.

I wrongly assumed the error I was getting has something to do with async function that I haven’t learned yet.
The cause was actually in passing the return of the function to a different function.
The code seems to be working fine. Thank you.