# Keep Getting Promise { \<Pending\> } When Returning Current Version of Extension and Latest Version in Hub

**URL:** <https://community.dynatrace.com/t/keep-getting-promise-pending-when-returning-current-version-of-extension-and-latest-version-in-hub/55526>\
**Category:** Automations\
**Tags:** coding-assistance, workflows, dashboards\
**Created:** [April 10, 2026, 10:52am UTC](https://community.dynatrace.com/t/keep-getting-promise-pending-when-returning-current-version-of-extension-and-latest-version-in-hub/55526 "2026-04-10T10:52:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![badgerfifteen](https://avatars.discourse-cdn.com/v4/letter/b/e68b1a/32.png) [@badgerfifteen](https://community.dynatrace.com/u/badgerfifteen)\
**Post date:** [April 10, 2026, 10:52am UTC](https://community.dynatrace.com/t/keep-getting-promise-pending-when-returning-current-version-of-extension-and-latest-version-in-hub/55526/1 "2026-04-10T10:52:49Z")

</div>

Hi all,

I’m currently working on a Code dashboard tile which shows the current version of an extension in relation to the latest version posted in the hub. I’m hoping to use this code for Workflows so I can be notified when extensions fall out of date. But I need to get over this first hurdle.

This is the code I have created so far:

```javascript
async function checkVersion(extensionName) {
  // fetching extensions from the hub
  const response = await fetch(
    'https://{environmentid}.live.dynatrace.com/api/v2/hub/extensions2/' + extensionName,
    {
      headers: {
        method: "GET",
        Accept: "application/json; charset=utf-8",
        'Authorization': 'Api-Token <REDACTED>'
      }
    }
  );
  const result = await response.json();
  return result.extension2Details.recommendedCatalogVersion;
}

export default async function () {

  // fetching current extensions in environment
  const response = await fetch(
    'https://{environmentid}.live.dynatrace.com/api/v2/extensions',
    {
      headers: {
        method: "GET",
        Accept: "application/json",
        'Authorization': 'Api-Token <REDACTED>'
      }
    }
  );
  const result = await response.json();

  const itemsArray = Object.values(result.extensions);

  const filteredItems = itemsArray.map(extension => ({
    'Extension Name': extension.extensionName,
    'Version': extension.version,
    'Version To Date': checkVersion(extension.extensionName).then()
  }));

  //console.log(checkVersion("com.dynatrace.filesystem").then());
  return filteredItems;
}

```

I realise this may be an issue with items not being resolved yet as part of the **checkVersion()** function but even manually calling it makes this appear in the console:

```markup
Promise { <pending> }

```

..which I assume is happening in the table generated from this, too.

If I use await like this:

```markup
await checkVersion("com.dynatrace.filesystem")

```

…I do get some data back, but I can’t use it in the mapping function as I get this:

```markup
"message": "Parse error: await isn't allowed in non-async function at file:///script.ts:34:30\n\n 'Version To Date': await checkVersion(extension.extensionName)

```

---

<div class="post-metadata">

**Author:** ![Evan1](https://avatars.discourse-cdn.com/v4/letter/e/e47c2d/32.png) [@Evan1](https://community.dynatrace.com/u/Evan1)\
**Post date:** [April 10, 2026, 12:11pm UTC](https://community.dynatrace.com/t/keep-getting-promise-pending-when-returning-current-version-of-extension-and-latest-version-in-hub/55526/2 "2026-04-10T12:11:16Z")

</div>

Hi&nbsp; **badgerfifteen,**

As the error message indicates, you must be in an asynchronous function to use the “await” prefix. This prefix is ​​necessary to wait for the promise to resolve before proceeding to the next step. Currently, your function is asynchronous, but the mapping is not:

```javascript
const filteredItems = itemsArray.map(extension => ({ // No async prefix here
    'Extension Name': extension.extensionName,
    'Version': extension.version,
    'Version To Date': checkVersion(extension.extensionName).then() // Need to be proceed before  
}));

```

You need to have something like that :

```javascript
itemsArray.map(async (extension) => ({
  ...
})

```

To fix this, you can do :

```javascript
async function checkVersion(extensionName) {
  // fetching extensions from the hub
  const response = await fetch(
    'https://{environmentid}.live.dynatrace.com/api/v2/hub/extensions2/' + extensionName,
    {
      headers: {
        method: "GET",
        Accept: "application/json; charset=utf-8",
        'Authorization': 'Api-Token <REDACTED>'
      }
    }
  );
  const result = await response.json();
  return result.extension2Details.recommendedCatalogVersion;
}

export default async function () {
  // fetching current extensions in environment
  const response = await fetch(
    'https://{environmentid}.live.dynatrace.com/api/v2/extensions',
    {
      headers: {
        method: "GET",
        Accept: "application/json",
        'Authorization': 'Api-Token <REDACTED>'
      }
    }
  );
  const result = await response.json();

  const itemsArray = Object.values(result.extensions);

  // Use Promise.all to handle asynchronous operations
  const filteredItems = await Promise.all(itemsArray.map(async (extension) => {
    const versionToDate = await checkVersion(extension.extensionName);
    return {
      'Extension Name': extension.extensionName,
      'Version': extension.version,
      'Version To Date': versionToDate
    };
  }));

  return filteredItems;
}

```

Let me know if it fix your problem

Have a nice day,

Sincerely
