diff --git a/components/footer.js b/components/footer.js index 3369288..22abec3 100644 --- a/components/footer.js +++ b/components/footer.js @@ -9,7 +9,7 @@ export default function Footer() {

- Made with by Midblep + Made with updateMeowCount()} /> by Midblep
NextJS // Vercel // Airtable @@ -19,4 +19,39 @@ export default function Footer() {

) +} + +async function updateMeowCount() { + const getMeow = await fetch("https://api.airtable.com/v0/appQnOyKBnBVQXLUM/Meows", { + method: "GET", + headers: { + 'Content-Type': 'application/json', + "Authorization": "Bearer " + process.env.AIRTABLE, + } + }); + + let meowCount = await getMeow.json(); + meowCount = parseInt(meowCount['records'][0]['fields']['count']); + meowCount++; + + const updateMeow = { + "records": [ + { + "id": "recR9RbScmJUPGQem", + "fields": { + "count": meowCount + "" + } + } + ] + }; + + await fetch("https://api.airtable.com/v0/appQnOyKBnBVQXLUM/Meows", { + method: "PATCH", + headers: { + 'Content-Type': 'application/json', + "Authorization": "Bearer " + process.env.AIRTABLE, + "accept": "application/json", + }, + body: JSON.stringify(updateMeow) + }); } \ No newline at end of file diff --git a/package.json b/package.json index cbe4445..4cb2738 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@fortawesome/free-solid-svg-icons": "^5.15.3", "@fortawesome/react-fontawesome": "^0.1.14", "@types/react": "^17.0.11", + "airtable": "^0.11.1", "googleapis": "^78.0.0", "next": "10.x", "next-images": "^1.8.1",