import Head from 'next/head'
import styles from '../styles/Gallery.module.css'
import Header from '../components/header';
import Footer from '../components/footer';
export default function Gallery({ response }) {
let images = [];
for(const key in response) {
let item = response[key];
images.push(item['fields']);
}
return (
Trick - Gallery
Gallery
{images.map((image) => (
{image.name}
))}
)
}
async function getGallery() {
const req = await fetch("https://api.airtable.com/v0/appQnOyKBnBVQXLUM/Gallery", {
method: "GET",
headers: {
'Content-Type': 'application/json',
"Authorization": "Bearer " + process.env.AIRTABLE,
}
});
const data = await req.json();
return data['records'];
}
export async function getServerSideProps() {
return {
props: {
response: await getGallery()
}
}
}