Hi folks, I’m very much a newbie so I hope you’ll forgive a basic question.
I’ve completed the Forge Introduction tutorial (it was very good) and got everything working. But there is a bit of a gap between those and the suggested “next steps” pages.
At the moment, I just want to enhance the app I created in the tutorial to display the value of a field in the issue, and then let me update that field. Quite a simple idea, but I’m struggling to figure that out. I’m looking at the sample apps, some of which are quite sophisticated, but so far I haven’t cracked it.
Your assistance would be appreciated, whether with a code sample or pointing me in the right direction. Thanks!
Update
I managed to read the field by hacking the code in the tutorial and some trial and error. I created this little function in the index.js:
const fetchStatusForIssue = async (issueId) => {
const res = await api
.asUser()
.requestJira(route`/rest/api/3/issue/${issueId}?fields=status`);
const data = await res.json();
return data;
};
And I called it like this:
const [status] = useState(async () => await fetchStatusForIssue(context.platformContext.issueKey));
console.log(`Status of this issue: ${status.fields.status.name}`);
My question now is whether there is a more elegant way to do this?