meowcount!!

main
Midnight 3 years ago
parent 24c0e4ba37
commit d0f20363c2

@ -9,7 +9,7 @@ export default function Footer() {
<div className="container">
<p>
<b>
Made with <FontAwesomeIcon icon={faHeart} style={{color: "#63C5DA"}} size="1x" id="clickMeow" /> by <a href="https://twitter.com/midblep" className="link" target="_blank">Midblep</a>
Made with <FontAwesomeIcon icon={faHeart} style={{color: "#63C5DA"}} size="1x" id="clickMeow" onClick={() => updateMeowCount()} /> by <a href="https://twitter.com/midblep" className="link" target="_blank">Midblep</a>
</b>
<br/>
NextJS // Vercel // Airtable
@ -19,4 +19,39 @@ export default function Footer() {
<script src="js/meow.js"></script>
</div>
)
}
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)
});
}

@ -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",

Loading…
Cancel
Save