feat: use new db site, cache requests to avoid repeated unneeded fetch calls
This commit is contained in:
+6
-7
@@ -7,6 +7,7 @@ import shared from '../../styles/shared.module.css';
|
||||
import styles from '../../styles/Items.module.css';
|
||||
|
||||
import { Item, Offering } from './types';
|
||||
import { fetchItems, fetchOfferings } from '../../lib/db';
|
||||
import ItemGrid from './ItemGrid';
|
||||
import OfferingGrid from './OfferingGrid';
|
||||
|
||||
@@ -23,13 +24,11 @@ export default function ItemsPage() {
|
||||
const [randMax, setRandMax] = useState(200);
|
||||
|
||||
useEffect(() => {
|
||||
Promise.all([
|
||||
fetch('/data/items.json').then(r => r.json()).catch(() => []),
|
||||
fetch('/data/offerings.json').then(r => r.json()).catch(() => []),
|
||||
]).then(([i, o]) => {
|
||||
setItems(i);
|
||||
setOfferings(o);
|
||||
});
|
||||
Promise.all([fetchItems(), fetchOfferings()])
|
||||
.then(([i, o]) => {
|
||||
setItems(i);
|
||||
setOfferings(o);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleClearAll = () => {
|
||||
|
||||
Reference in New Issue
Block a user