Hello everybody,
i am new to Forge dev environment, so excuse me for asking a question like this. I am coming from the Java world so i am trying to familiarise myself with React etc.
So my problem is that, i want to have an extra issue panel in my issue and try to render some values in it, like a table etc. But i can not figure out the correct way to fetch the data from the backend and render them correctly. I see a lot of undefined/null returns
Below is the code i use.
index.js
resolver.define('fetchMainIssues', async (req) => {
console.log(req);
const obj = JSON.parse(JSON.stringify(req));
const epicIssueId = obj.context.extensionContext.issueKey
console.log("Current Issue: " + obj.context.extensionContext.issueKey);
const xxx = fetchIssuesOfEpic(epicIssueId)
.then(response => {
const listOfIssueKeysInEpic = []
//get issues of Epic
for (const issue of response.issues) {
listOfIssueKeysInEpic.push(issue.key)
}
return listOfIssueKeysInEpic
}
)
return xxx
}
)
async function fetchIssuesOfEpic(issueId) {
const result = await api.asApp().requestJira(`/rest/api/3/search?jql="Epic Link"=${issueId} Order By key ASC`);
const json = await result.json();
return json
}
App.js
const [data, setData] = useState(null);
useEffect(() => {
if (!data) return;
Promise.all(
data.map((data) => {
console.log("In Promise: " + data)
return data;
//invoke('fetchMainIssues', { example: 'my-invoke-variable' })
})
)
.then((saved) => saved.filter((a) => a))
.then(setData);
},[data]);
const Panel = () => (
<Fragment>
{data.map((i) => {
return (<Text>{i}</Text>)
})}
</Fragment>
);
As you see its a combination of code snippets found in Forge Examples Repos or here in the community. I read the code again and again, i think i understand whats going on, but i miss the result at the end . So any help will be amazing
Thanks in advance and sorry for the long post
Regards