Got async startup funcs for NFT page

This commit is contained in:
Chris Troutner
2025-02-04 17:14:47 -07:00
parent 7981c7fb1f
commit 9f4f972880
+15 -3
View File
@@ -22,6 +22,9 @@ function NftsForSale (props) {
const appData = props.appData
console.log('NftsForSale() appData: ', appData)
// State
const [offers, setOffers] = useState([])
async function getNftOffers(page = 0) {
try {
const options = {
@@ -66,16 +69,19 @@ function NftsForSale (props) {
async function handleOffers() {
let offers = await getNftOffers()
console.log('offers: ', offers)
return offers
}
async function handleStartProcessingTokens() {
await handleOffers()
return await handleOffers()
}
// This is an async startup function that is called by the useEffect hook.
const asyncStartup = async () => {
try {
await handleStartProcessingTokens()
const offers = await handleStartProcessingTokens()
setOffers(offers)
} catch (error) {
console.error('NftsForSale() asyncStartup() error: ', error)
}
@@ -84,7 +90,7 @@ function NftsForSale (props) {
// Load NFT data when the page loads from the server or from the cache.
useEffect(() => {
asyncStartup()
}, [])
}, [offers])
return (
<Container>
@@ -92,6 +98,12 @@ function NftsForSale (props) {
<Col>
<h1>NFTs for Sale</h1>
</Col>
<Col xs={6}>
<Button variant='success' >
<FontAwesomeIcon icon={faRedo} size='lg' /> Refresh
</Button>
</Col>
</Row>
</Container>
)