# Fetching Data from External API - Parse into Table

**URL:** <https://community.dynatrace.com/t/fetching-data-from-external-api-parse-into-table/52955>\
**Category:** Dashboarding\
**Tags:** dynatrace-managed, dashboards, dynatrace-api\
**Created:** [August 14, 2025, 2:50pm UTC](https://community.dynatrace.com/t/fetching-data-from-external-api-parse-into-table/52955 "2025-08-14T14:50:52Z")\
**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:** [August 14, 2025, 2:50pm UTC](https://community.dynatrace.com/t/fetching-data-from-external-api-parse-into-table/52955/1 "2025-08-14T14:50:52Z")

</div>

Hi all,

Due to limitations in Grail currently (from previous post), I’m trying to get data from the Dynatrace API into a dashboard. I am using this code in Dynatrace:

```markup
export default async function () {
  const fake_api_token = 'dtc10.faketoken';
  const response = await fetch('https://api.dynatrace.com/kdsdkeokkdeokfoekfeofko');
  const result = response.json();
  return result;

```

The query successfully returns but it is all bunched up in the column result. I’ve tried doing things like result.value and result.data so it auto-formats into a table but it does not.

I am using the Dynatrace Metrics Query V2 from the API and have been following this article:

[Add code to a dashboard — Dynatrace Docs](https://docs.dynatrace.com/docs/analyze-explore-automate/dashboards-and-notebooks/dashboards-new/components/dashboard-component-code)

---

<div class="post-metadata">

**Author:** ![luis\_alcantara](https://avatars.discourse-cdn.com/v4/letter/l/47e85d/32.png) [@luis\_alcantara](https://community.dynatrace.com/u/luis_alcantara)\
**Post date:** [August 26, 2025, 2:35pm UTC](https://community.dynatrace.com/t/fetching-data-from-external-api-parse-into-table/52955/2 "2025-08-26T14:35:24Z")

</div>

Hi,

I tested the code you sent, and I changed it to extract the SLOs using the Dynatrace API and you’re right—it returns a table with the API results, and one column contains the information (in my case, it’s called “slo”) when using “return result”, as shown below:

_Code:_

```javascript
export default async function () {
  const token = 'dt0c01.token';
  const response = await fetch('https://dynatrace.com/e/8436fe7/api/v2/slo', {
  headers: {
    Accept: "application/json",
    Authorization: "Api-Token " + token
  }});
  const result = response.json();

  return result;
}

```

_Result:_

 ![luis_alcantara_0-1756218362798.png](https://global.discourse-cdn.com/dynatrace/original/3X/9/3/938a66f013456e8c5efe937d5b4aeafe2ba7b507.png)

If we try to use return “result.slo”, it shows that there’s no data:

_Code:_

```javascript
export default async function () {
  const token = 'dt0c01.token';
  const response = await fetch('https://dynatrace.com/e/8436fe7/api/v2/slo', {
  headers: {
    Accept: "application/json",
    Authorization: "Api-Token " + token
  }});
  const result = response.json();

  return result.slo;
}

```

_Result:_

 ![luis_alcantara_1-1756218615980.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/6/06c6c08a6283e316a051aa519a1e870b2504f718.png)

So, I then tried adding “await” to “const result = response.json();”, making it “const result = await response.json();”, and that did return the table with the SLOs. Just to clarify, I added the headers because the API call requires authorization:

_Code:_

```javascript
export default async function () {
  const token = 'dt0c01.token';
  const response = await fetch('https://dynatrace.com/e/8436fe7/api/v2/slo', {
  headers: {
    Accept: "application/json",
    Authorization: "Api-Token " + token
  }});
  const result = await response.json();

  return result.slo;
}

```

_Result:_

 ![luis_alcantara_3-1756218814467.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/9/c99158cf85b1c29a7af255d8a9e857a21a4df429.png)

I’m not sure if this answers your question, but if you have any other doubts, please feel free to ask.
