# array.map is only a function in another cell

**URL:** <https://talk.observablehq.com/t/array-map-is-only-a-function-in-another-cell/4173>\
**Category:** Help\
**Created:** [November 19, 2020, 12:42pm UTC](https://talk.observablehq.com/t/array-map-is-only-a-function-in-another-cell/4173 "2020-11-19T12:42:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LukasGrebe](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/lukasgrebe/32/2368_2.png) [@LukasGrebe](https://talk.observablehq.com/u/LukasGrebe)\
**Post date:** [November 19, 2020, 12:42pm UTC](https://talk.observablehq.com/t/array-map-is-only-a-function-in-another-cell/4173/1 "2020-11-19T12:42:59Z")

</div>

i have 3 cells:

A: gets data from an IndexDB via its JS API `query = flux => QueryAPI.collectRows(flux)`

B: provides a flux Query to execute via A and assigns the result to a variable `data = query('from(… <query>')`  
The cell Return value is an Array

C: Transforms data via array.map

I wanted to combine Cells B and C so `data = query(…).map(…)` and i get the error `undefined is not a function`

i cant fathom why moving code from within a cell to a separate cell would yield such an error. Maybe some async/promise magic? but adding an await before function calls only puts out more errors.

---

<div class="post-metadata">

**Author:** ![severo](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/severo/32/786_2.png) [@severo](https://talk.observablehq.com/u/severo)\
**Post date:** [November 19, 2020, 1:43pm UTC](https://talk.observablehq.com/t/array-map-is-only-a-function-in-another-cell/4173/2 "2020-11-19T13:43:07Z")

</div>

yes, maybe `(await query(...)).map(...)`, or equivalently `query(...).then(d => d.map(...))`

The “magic” when separating in different cells is that every cell is “awaited” automatically, so that if the cell contains a Promise, its value will be the resolved or rejected value. See [https://observablehq.com/@observablehq/introduction-to-promises?collection=@observablehq/javascript-in-observable](https://observablehq.com/@observablehq/introduction-to-promises?collection=@observablehq/javascript-in-observable) for example.
