let select_options = []
export const serverCall = async (value) => {
try {
const response = await axois.post('test/', value)
.catch(error => {
some error code ..
}
})
if (response && response.data) {
select_options = response.data
}
} catch (error) {
} finally {
}
}
export async function makeSelectTag(type_code,group_code) {
await serverCall({'type_code':type_code,'group_code':group_code})
console.log(select_options) //It clearly contains the value I want.
return (<Select style={{ width: 150 }} >
{options.map((item) => (
<Option key={item.code_id}>{item.code_name}</Option>
))}
</Select>
);
}
export default(commonCodeCall, makeSelectTag)
The code above is called from the code below.
import makeSelectTag from '../myPath'
....
return (
<div>
<Form.Item>
{makeSelectTag('type_code','group_code')}
</Form.Item>
...
Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.
How can I solve the problem and make it work?