<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Keep Getting Promise { &amp;lt;Pending&amp;gt; } When Returning Current Version of Extension and Latest Version in Hub in Automations</title>
    <link>https://community.dynatrace.com/t5/Automations/Keep-Getting-Promise-lt-Pending-gt-When-Returning-Current/m-p/297532#M2553</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;STRONG&gt;badgerfifteen,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const filteredItems = itemsArray.map(extension =&amp;gt; ({ // No async prefix here
    'Extension Name': extension.extensionName,
    'Version': extension.version,
    'Version To Date': checkVersion(extension.extensionName).then() // Need to be proceed before  
}));&lt;/LI-CODE&gt;&lt;P&gt;You need to have something like that :&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;itemsArray.map(async (extension) =&amp;gt; ({
  ...
})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To fix this, you can do :&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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 &amp;lt;REDACTED&amp;gt;'
      }
    }
  );
  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 &amp;lt;REDACTED&amp;gt;'
      }
    }
  );
  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) =&amp;gt; {
    const versionToDate = await checkVersion(extension.extensionName);
    return {
      'Extension Name': extension.extensionName,
      'Version': extension.version,
      'Version To Date': versionToDate
    };
  }));

  return filteredItems;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if it fix your problem&lt;/P&gt;&lt;P&gt;Have a nice day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sincerely&lt;/P&gt;</description>
    <pubDate>Fri, 10 Apr 2026 12:11:16 GMT</pubDate>
    <dc:creator>Evan1</dc:creator>
    <dc:date>2026-04-10T12:11:16Z</dc:date>
    <item>
      <title>Keep Getting Promise { &lt;Pending&gt; } When Returning Current Version of Extension and Latest Version in Hub</title>
      <link>https://community.dynatrace.com/t5/Automations/Keep-Getting-Promise-lt-Pending-gt-When-Returning-Current/m-p/297522#M2552</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the code I have created so far:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;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 &amp;lt;REDACTED&amp;gt;'
      }
    }
  );
  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 &amp;lt;REDACTED&amp;gt;'
      }
    }
  );
  const result = await response.json();

  const itemsArray = Object.values(result.extensions);

  const filteredItems = itemsArray.map(extension =&amp;gt; ({
    'Extension Name': extension.extensionName,
    'Version': extension.version,
    'Version To Date': checkVersion(extension.extensionName).then()
  }));

  //console.log(checkVersion("com.dynatrace.filesystem").then());
  return filteredItems;
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;I realise this may be an issue with items not being resolved yet as part of the &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;checkVersion()&lt;/FONT&gt;&lt;/STRONG&gt; function but even manually calling it makes this appear in the console:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Promise { &amp;lt;pending&amp;gt; }&lt;/LI-CODE&gt;
&lt;P&gt;..which I assume is happening in the table generated from this, too.&lt;/P&gt;
&lt;P&gt;If I use await like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;await checkVersion("com.dynatrace.filesystem")&lt;/LI-CODE&gt;
&lt;P&gt;…I do get some data back, but I can't use it in the mapping function as I get this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;"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)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2026 07:36:32 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Keep-Getting-Promise-lt-Pending-gt-When-Returning-Current/m-p/297522#M2552</guid>
      <dc:creator>badgerfifteen</dc:creator>
      <dc:date>2026-04-13T07:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: Keep Getting Promise { &lt;Pending&gt; } When Returning Current Version of Extension and Latest Version in Hub</title>
      <link>https://community.dynatrace.com/t5/Automations/Keep-Getting-Promise-lt-Pending-gt-When-Returning-Current/m-p/297532#M2553</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;STRONG&gt;badgerfifteen,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const filteredItems = itemsArray.map(extension =&amp;gt; ({ // No async prefix here
    'Extension Name': extension.extensionName,
    'Version': extension.version,
    'Version To Date': checkVersion(extension.extensionName).then() // Need to be proceed before  
}));&lt;/LI-CODE&gt;&lt;P&gt;You need to have something like that :&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;itemsArray.map(async (extension) =&amp;gt; ({
  ...
})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To fix this, you can do :&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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 &amp;lt;REDACTED&amp;gt;'
      }
    }
  );
  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 &amp;lt;REDACTED&amp;gt;'
      }
    }
  );
  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) =&amp;gt; {
    const versionToDate = await checkVersion(extension.extensionName);
    return {
      'Extension Name': extension.extensionName,
      'Version': extension.version,
      'Version To Date': versionToDate
    };
  }));

  return filteredItems;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if it fix your problem&lt;/P&gt;&lt;P&gt;Have a nice day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sincerely&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2026 12:11:16 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Keep-Getting-Promise-lt-Pending-gt-When-Returning-Current/m-p/297532#M2553</guid>
      <dc:creator>Evan1</dc:creator>
      <dc:date>2026-04-10T12:11:16Z</dc:date>
    </item>
  </channel>
</rss>

