# Forge runtime not found error

**URL:** <https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149>\
**Category:** Forge UI Kit and Custom UI\
**Tags:** forge-ui, forge-api, jira-cloud, rest-api, forge\
**Created:** [January 15, 2023, 1:06pm UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149 "2023-01-15T13:06:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![SuvarnaGaikwad](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@SuvarnaGaikwad](https://community.developer.atlassian.com/u/SuvarnaGaikwad)\
**Post date:** [January 15, 2023, 1:06pm UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/1 "2023-01-15T13:06:45Z")

</div>

am trying to run below api in my forge app and getting this error after deployment  
const response = await api.asUser().requestJira(route`/rest/api/3/field`, {  
headers: {  
‘Accept’: ‘application/json’  
}  
});

Error:  
runtime.js:7 Uncaught (in promise) Error: Forge runtime not found.  
at t.getRuntime (runtime.js:7:15)  
at fetch.js:12:41  
at Object.requestJira (index.js:13:12)  
at App.js:65:43  
at f (regeneratorRuntime.js:44:17)  
at Generator. (regeneratorRuntime.js:125:22)  
at Generator.next (regeneratorRuntime.js:69:21)  
at h (asyncToGenerator.js:3:20)  
at a (asyncToGenerator.js:22:9)  
at asyncToGenerator.js:27:7

How to fix this? can anyone please help?

---

<div class="post-metadata">

**Author:** ![AlexeyKotlyarov](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/alexeykotlyarov/32/45643_2.png) [@AlexeyKotlyarov](https://community.developer.atlassian.com/u/AlexeyKotlyarov)\
**Post date:** [January 15, 2023, 10:09pm UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/2 "2023-01-15T22:09:44Z")

</div>

Are you running this code in the backend, or the UI code? `@forge/api`, including `requestJira`, only works inside the backend functions.

---

<div class="post-metadata">

**Author:** ![SuvarnaGaikwad](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@SuvarnaGaikwad](https://community.developer.atlassian.com/u/SuvarnaGaikwad)\
**Post date:** [January 16, 2023, 1:51am UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/3 "2023-01-16T01:51:10Z")

</div>

@AlexeyKotlyarov am now trying to use requestJirs from forge/bridge. it return data in function (can console.log) but when returning in main, it is returning promise object. not sure how to resolve this. also not sure how to read this object. any help is appreciated.

---

<div class="post-metadata">

**Author:** ![AlexeyKotlyarov](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/alexeykotlyarov/32/45643_2.png) [@AlexeyKotlyarov](https://community.developer.atlassian.com/u/AlexeyKotlyarov)\
**Post date:** [January 16, 2023, 2:12am UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/4 "2023-01-16T02:12:54Z")

</div>

The `@forge/bridge` is the right solution for making requests from the UI.

Here’s a nice guide for working with promises: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using\_promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises)

If you are still having problems, please share your code, the results you are seeing and what you expected to happen instead.

---

<div class="post-metadata">

**Author:** ![SuvarnaGaikwad](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@SuvarnaGaikwad](https://community.developer.atlassian.com/u/SuvarnaGaikwad)\
**Post date:** [January 16, 2023, 2:20am UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/5 "2023-01-16T02:20:32Z")

</div>

@AlexeyKotlyarov here is the code  
import { requestJira } from ‘@forge/bridge’;

const getCustomfields = async() =\> {  
const response = await requestJira(`/rest/api/3/field`);

console.log(`Response: ${response.status} ${response.statusText}`);

const data = await response.json();  
[//console.log](https://console.log)("len in custom field: " + data.length);  
console.log(data);  
return data;  
};

function App() {  
const context = useProductContext();  
const [allFields] = useState(async() =\> await getCustomfields());  
console.log("fields: " + allFields);  
}

console.log in getCustomfields returns json array correctly.  
but in function app, console.log returns **fields: [object Promise]**

what could be an issue? I want json array in function app as well as want to use it further.

---

<div class="post-metadata">

**Author:** ![PeterYu](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@PeterYu](https://community.developer.atlassian.com/u/PeterYu)\
**Post date:** [January 16, 2023, 3:06am UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/6 "2023-01-16T03:06:10Z")

</div>

Hi @SuvarnaGaikwad,

You are setting your initial state with an async function, so the `allFields` variable will be a Promise. React also won’t wait on that initialiser function before it performs the render, so there’s no guarantee that the promise will have resolved by the time the value is logged.

A more idiomatic approach would be to fetch the data with a `useEffect` hook, and setting the result of that in a non-Promise state variable.

```auto
function App() {
  const context = useProductContext();
  const [allFields, setAllFields] = useState([]);
  useEffect(() => {
    getCustomFields().then(setAllFields);
  }, []);
  console.log("fields: " + allFields);
}

```

---

<div class="post-metadata">

**Author:** ![SuvarnaGaikwad](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@SuvarnaGaikwad](https://community.developer.atlassian.com/u/SuvarnaGaikwad)\
**Post date:** [January 16, 2023, 3:30am UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/7 "2023-01-16T03:30:23Z")

</div>

useEffect function can detect only methods within function App. as requestJira needs to be async; have defined it in top level outside function App. so getCustomFields within useEffect could not detect method

---

<div class="post-metadata">

**Author:** ![PeterYu](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@PeterYu](https://community.developer.atlassian.com/u/PeterYu)\
**Post date:** [January 16, 2023, 3:53am UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/8 "2023-01-16T03:53:34Z")

</div>

@SuvarnaGaikwad I have tested that it is possible for `useEffect` to call functions outside of `App`, since the function should be in global scope. Can you show the error you’re getting?

---

<div class="post-metadata">

**Author:** ![SuvarnaGaikwad](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@SuvarnaGaikwad](https://community.developer.atlassian.com/u/SuvarnaGaikwad)\
**Post date:** [January 16, 2023, 4:42am UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/9 "2023-01-16T04:42:49Z")

</div>

getting the error in console that getCustomFields is not defined

---

<div class="post-metadata">

**Author:** ![AlexeyKotlyarov](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/alexeykotlyarov/32/45643_2.png) [@AlexeyKotlyarov](https://community.developer.atlassian.com/u/AlexeyKotlyarov)\
**Post date:** [January 16, 2023, 10:14pm UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/10 "2023-01-16T22:14:34Z")

</div>

Names in JavaScript are case-sensitive. Please check that you are using `getCustomFields` or `getCustomfields` (lowercase F) consistently!

---

<div class="post-metadata">

**Author:** ![ChrisLow](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@ChrisLow](https://community.developer.atlassian.com/u/ChrisLow)\
**Post date:** [February 23, 2023, 6:09pm UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/11 "2023-02-23T18:09:07Z")

</div>

I’m getting the same error - `Forge runtime not found` - but not for `requestJira()`, which I was already using through the Custom UI bridge. Instead, I’m trying to use [https://developer.atlassian.com/platform/forge/runtime-reference/properties-api/#onjiraproject](https://developer.atlassian.com/platform/forge/runtime-reference/properties-api/#onjiraproject) and [https://developer.atlassian.com/platform/forge/runtime-reference/storage-api/](https://developer.atlassian.com/platform/forge/runtime-reference/storage-api/). The documentation appears to indicate that these are only available via `@forge/api`. I welcome thoughts on how to proceed.

@AlexeyKotlyarov - would you elaborate on the following comment? What would be backend code, and what would be UI code? I’m uncertain where that line is drawn.

> Are you running this code in the backend, or the UI code? `@forge/api` , including `requestJira` , only works inside the backend functions.

---

<div class="post-metadata">

**Author:** ![ChrisLow](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@ChrisLow](https://community.developer.atlassian.com/u/ChrisLow)\
**Post date:** [February 23, 2023, 6:20pm UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/12 "2023-02-23T18:20:48Z")

</div>

@AlexeyKotlyarov - when you mention backend vs. UI, are you alluding to [https://developer.atlassian.com/platform/forge/runtime-reference/custom-ui-resolver/](https://developer.atlassian.com/platform/forge/runtime-reference/custom-ui-resolver/)?

---

<div class="post-metadata">

**Author:** ![AlexeyKotlyarov](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/alexeykotlyarov/32/45643_2.png) [@AlexeyKotlyarov](https://community.developer.atlassian.com/u/AlexeyKotlyarov)\
**Post date:** [February 23, 2023, 10:17pm UTC](https://community.developer.atlassian.com/t/forge-runtime-not-found-error/65149/13 "2023-02-23T22:17:31Z")

</div>

The backend is anything that ultimately runs through a `function` module, e.g. Web triggers and modules implemented using UI Kit.

Custom UI code runs in the users’ browsers and has no direct access to the Forge runtime. Therefore methods from `@forge/api` have to be invoked through the Custom UI bridge.
