Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

External APi calls to populate custom field

Matthew Thomas
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 20, 2023

I'm creating a new custom module for 

jira:customField:

When i try to use 

import {fetch} from "@forge/api";

 

useEffect(() => {
fetch("XXXXXXXX").then(resp => {
console.info(resp)
})
}, []);


Just as an example to get a list of data from a json endpoint to populate the select list, I don't see this output in the tunnel logs or browser console.

Here is a demo example also not firing

const [test, setTest] = useState([])

useEffect(() => {
fetch("https://myapi.com/resp.json").then(resp => {
setTest([{label: "test", value: "123"}])
})
}, []);

return (
<CustomFieldEdit onSubmit={onSubmit}>
<Select label="Harvest Work Orders" name="harvestworkorders">
{test.map(el => {
return <Option label={el.label} value={el.value} />
})}

</Select>
</CustomFieldEdit>
);


The mainfest file allows this call I've hardcoded a response to set just for testing but still nothing occurs, if I remove the fetch the hardcode works so it seems using fetch doesn't trigger the external api call but I cannot fathom as too why, This seems to work fine if I create a

jira:issueContext


but ideally this would be better as a custom form field but perhaps this is not possible and I will have to go down the other route?

1 answer

1 accepted

0 votes
Answer accepted
Matthew Thomas
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 24, 2023

For anyone else that comes across this I ended up going down the custom field context to pre-populate values. Which is OK for my use case.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events