# Unexpected token Error in Confluence Search API Call

**URL:** <https://community.developer.atlassian.com/t/unexpected-token-error-in-confluence-search-api-call/46438>\
**Category:** Forge\
**Tags:** search, nodejs, confluence-cloud, rest-api\
**Created:** [March 22, 2021, 3:52pm UTC](https://community.developer.atlassian.com/t/unexpected-token-error-in-confluence-search-api-call/46438 "2021-03-22T15:52:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JimmySeddon](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/jimmyseddon/32/46553_2.png) [@JimmySeddon](https://community.developer.atlassian.com/u/JimmySeddon)\
**Post date:** [March 22, 2021, 3:52pm UTC](https://community.developer.atlassian.com/t/unexpected-token-error-in-confluence-search-api-call/46438/1 "2021-03-22T15:52:21Z")

</div>

Hello Everyone,

I’m fairly new to Forge and I’m trying to start by writing my own app that will make use of the Search API to display some information in a table.

When running a ‘forge deploy’. I’m getting the following error:

```auto
Running forge lint...
Error: unknown: Unexpected token, expected ";" (69:25)
  67 | 
  68 | function getSearchResults(searchAPI) {
> 69 | let response = await api.asUser().requestConfluence(searchAPI, {
   | ^
  70 | headers: {
  71 | 'Accept': 'application/json'
  72 | }

```

I’ve looked over the entire function multiple times, and I can’t see where I have made my mistake:

```auto
function getSearchResults(searchAPI) {
    const response = await api.asUser().requestConfluence(searchAPI, {
      headers: {
        'Accept': 'application/json'
      }
    });
    return response.json;
  }

```

Does anyone have any thoughts or suggestions on what I’ve done wrong? Or other things I should consider looking at to get to the root of my problems?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![bentley](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/bentley/32/36116_2.png) [@bentley](https://community.developer.atlassian.com/u/bentley)\
**Post date:** [March 22, 2021, 5:46pm UTC](https://community.developer.atlassian.com/t/unexpected-token-error-in-confluence-search-api-call/46438/2 "2021-03-22T17:46:13Z")

</div>

I believe that to make use of `await`, you need to make the function `async` so this:

> [@JimmySeddon](#):
>
> ```auto
> function getSearchResults(searchAPI) {
> 
> ```

becomes:

```auto
async function getSearchResults(searchAPI) {

```

More on async/await: [Async/await](https://javascript.info/async-await)

Curious to see if that changes anything.

---

<div class="post-metadata">

**Author:** ![JimmySeddon](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/jimmyseddon/32/46553_2.png) [@JimmySeddon](https://community.developer.atlassian.com/u/JimmySeddon)\
**Post date:** [March 22, 2021, 6:15pm UTC](https://community.developer.atlassian.com/t/unexpected-token-error-in-confluence-search-api-call/46438/3 "2021-03-22T18:15:20Z")

</div>

Thank you @bentley!

I hadn’t even thought about that being an issue. I’ll give that a try and let you know what happens.

-Jimmy

---

<div class="post-metadata">

**Author:** ![JimmySeddon](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/jimmyseddon/32/46553_2.png) [@JimmySeddon](https://community.developer.atlassian.com/u/JimmySeddon)\
**Post date:** [March 22, 2021, 6:24pm UTC](https://community.developer.atlassian.com/t/unexpected-token-error-in-confluence-search-api-call/46438/4 "2021-03-22T18:24:35Z")

</div>

That was exactly my issue! Thank you @bentley I really appreciate the quick response and the help getting past that issue!
