mirror of
https://github.com/System-End/site.git
synced 2026-04-19 22:05:11 +00:00
[arcade] Add gallery API
This commit is contained in:
parent
f9f91fa1eb
commit
b29a62371f
1 changed files with 33 additions and 0 deletions
33
pages/api/arcade/gallery.js
Normal file
33
pages/api/arcade/gallery.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import AirtablePlus from "airtable-plus"
|
||||
|
||||
const fetchPosts = async () => {
|
||||
const airtable = new AirtablePlus({
|
||||
apiKey: process.env.AIRTABLE_API_KEY,
|
||||
baseID: 'app4kCWulfB02bV8Q',
|
||||
tableName: 'Projects',
|
||||
})
|
||||
|
||||
const records = await airtable.read({
|
||||
filterByFormula: '{Status} = "Shipped"'
|
||||
})
|
||||
|
||||
return records.map(record => ({
|
||||
id: record.id,
|
||||
name: record.fields["Name"],
|
||||
desc: record.fields["Description"],
|
||||
slack: record.fields["Slack Handle"],
|
||||
codeLink: record.fields["Github Link"],
|
||||
playLink: record.fields["Playable Link"],
|
||||
images: record.fields["Screenshot / Video"],
|
||||
}))
|
||||
}
|
||||
|
||||
export default async function handler(req, res) {
|
||||
try {
|
||||
const data = await fetchPosts();
|
||||
res.status(200).json(data);
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
res.status(500).json({ error: 'Failed to fetch posts' });
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue