Can not get data from rest api in Forge Custom UI

I try to read data by using function :

import React, { useEffect ,useState,} from 'react';
import { invoke, requestJira } from '@forge/bridge';

const getProjects = async () => {
    const response= await requestJira('/rest/api/3/project');
    const data = await response.json();
    return data;
function App() {
    const [projects] = useState(() => getProjects());
  return (
      <textarea id="w3review" name="w3review" rows="4" cols="50">

export default App;    

and I get [Promise object ] as response

Please advise

Hi @OlgaMeltsin,

I think you need to utilise the useAction hook:

import {useAction} from "@forge/ui"; 

const [projects] = useAction(value => value, async () => await getProjects());


1 Like

Hi Dugald
Thank you for your reply!
I tried your suggestion, it doesn’t work, I am not getting any response, even [Promise object]

Async function returns a Promise object.

Read up on Promise (Promise - JavaScript | MDN) and async functions in general.

You will have a lot more surprises up ahead if you don’t know about how async functions work in JavaScript.

1 Like

Hi @OlgaMeltsin ,

Sorry, I was previously thinking this was Forge UI.

I think you need to use the useEffect hook and put the async function inside the useEffect hook as explained in How to use async functions in useEffect (with examples) - Devtrium.