The Code below successfully displays record from Storage API via Forge
const fetchRec = async () => {
const data = await storage.query().where('key', startsWith('Mykeysxxxxx')).getMany();
return data.results;
};
const App = () => {
const [ projects ] = useState(fetchRec);
return (
<Fragment>
// display or map projects records here
<Button text="Refresh Records" onClick={async () => { await reloadRec();}} />
</Fragment>
);
}
Here is my Issue.
I need to refresh the Records when new data is inserted.
So I implemented the code below. when I click on refresh Records button, the new added record is not updated
<Button text="Refresh Records" onClick={async () => { await reloadRec();}} />
async function reloadRec() {
fetchRec().then(projects);
}
Here is the entire Codes
const fetchRec = async () => {
const data = await storage.query().where('key', startsWith('Mykeysxxxxx')).getMany();
return data.results;
};
async function reloadRec() {
fetchRec().then(projects);
}
const App = () => {
const [projects] = useState(fetchRec);
return (
<Fragment>
// display or map projects records here
<Button text="Refresh Records" onClick={async () => { await reloadRec(); }} />
</Fragment>
);
}