Hi,
I am trying to fetch from a url, and in the meantime the app will crash:
# Unexpected error in app
An error occurred while trying to load this app.
* Refresh app
With no other error, is there any timeout on waiting for an update? Is there a way to increase the timeout or have the request happen in the background to not incur it?
Cheers,
B
import ForgeUI, { render, Fragment, Text, Button, IssuePanel, useState, Table, Head, Row, Cell } from '@forge/ui';
import api from '@forge/api';
import { useIssueProperty } from '@forge/ui-jira';
const getFixes = async (issueId) => {
const res = await api.fetch('https://x.y.org/fixes?change=' + issueId);
console.log(res)
return res.json()
};
const App = () => {
const [jobs, setJobs] = useIssueProperty("jobs", [2238765]);
// const [result, setResult] = useState(async () => await getFixes(2238765));
const [result, setResult] = useState({"Fixes": [{"Job": 'j1', "Status": "s1"}]});
// This log happens the second time but after the app has error'd, which leads me to think there is some timeout.
console.log(result.Fixes)
console.log(jobs[0])
debugger;
return (
<Fragment>
<Text>{jobs[0]}</Text>
<Text>{JSON.stringify(result)}</Text>
<Button
text="Update"
onClick={() => {
setResult((async () => {return await getFixes(jobs[0])})());
//setResult({"Fixes": [{"Job": 'j2', "Status": "s2"}]});
}} />
</Fragment>
);
};
export const run = render(
<IssuePanel>
<App />
</IssuePanel>
);