brilliant-orangeB
Refine9mo ago
9 replies
brilliant-orange

How to make an API request every time I submit?```

export default function MembershipList() {
const {
data: members,
isLoading,
isFetching,
isRefetching,
} = useList<IMember>({
resource: 'membership/subscribers',
filters: [
{
field: 'value',
operator: 'eq',
value: submittedSearch,
},
],
})


useEffect(() => {
const fetchCustomerGroups = async () => {
try {
const response = await fetch(${process.env.NEXT_PUBLIC_API_URL}/customergroups/detail, {
headers: {
'Content-Type': 'application/json',
'ngrok-skip-browser-warning': '69420',
},
})

<form onSubmit={handleSubmit}>
<CardContent sx={{ pt: 0 }}>
<Box mb={2}>
<Typography variant="h6"></Typography>
<Grid container spacing={2}>
<Grid item xs={12} sm={10}>
<TextField
value={searchField}
onChange={(e) => setSearchField(e.target.value)}
label={''}
placeholder={', , '}
margin="normal"
fullWidth
autoFocus
size="small"
variant="outlined"
sx={{ mt: 0, height: 40 }}
/>
</Grid>
</Grid>
</Box>
<Box display="flex" justifyContent="flex-end" width="100%">
<Button type="submit" variant="contained" sx={{ mr: 2 }}>

</Button>
<Button type="button" variant="contained" color="secondary" onClick={() => resetForm()}>

</Button>
</Box>
</CardContent>
</form>
```
Was this page helpful?