# I'm confused about why a function call returns an object but I can't access its properties

**URL:** <https://talk.observablehq.com/t/im-confused-about-why-a-function-call-returns-an-object-but-i-cant-access-its-properties/8315>\
**Category:** Help\
**Created:** [September 26, 2023, 5:57pm UTC](https://talk.observablehq.com/t/im-confused-about-why-a-function-call-returns-an-object-but-i-cant-access-its-properties/8315 "2023-09-26T17:57:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addem](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@addem](https://talk.observablehq.com/u/addem)\
**Post date:** [September 26, 2023, 5:57pm UTC](https://talk.observablehq.com/t/im-confused-about-why-a-function-call-returns-an-object-but-i-cant-access-its-properties/8315/1 "2023-09-26T17:57:04Z")

</div>

In this notebook I have a function which returns an object by means of a `fetch`. If I merely run the function it successfully returns the object.

> **[Color Boxes](https://observablehq.com/d/833e6df4d5db88bc)**
>
> The following is an implementation of color boxes, mostly taken from @anniez 's public notebook. I just wanted to make it a function so that I could color them differently throughout a document.

However, if I try to access that property, it returns as undefined. Can someone explain what’s going on there?

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [September 26, 2023, 6:06pm UTC](https://talk.observablehq.com/t/im-confused-about-why-a-function-call-returns-an-object-but-i-cant-access-its-properties/8315/2 "2023-09-26T18:06:19Z")

</div>

The function return the fetch Promise, which will resolve asynchronously when the resource is actually downloaded and processed. Add `await` before the promise and you will get its resolved value.

> const cn = await colorName(hex);
