DEV Community

Cover image for Dev OPinion - Netlify Dynamic Site Challenge Submission
Ishaan Sheikh
Ishaan Sheikh

Posted on • Edited on

Dev OPinion - Netlify Dynamic Site Challenge Submission

This is a submission for the Netlify Dynamic Site Challenge: Build with Blobs.

What I Built

I have built an online poll for the common questions between developers. Each question has two options. Users can choose any one option. The votes are recorded anonymously.

Demo

The demo is available here - devopinion.netlify.app

Source Code on GitHub -

GitHub logo frikishaan / devopinion

App for the Netlify Dynamic Site Challenge




Platform Primitives

Netlify Blobs

I have used Netlify Blobs to store the votes for each question.

Each blob holds a JSON array of votes for each option. Below is an example of data stored in a blob.

[341, 1231]
Enter fullscreen mode Exit fullscreen mode

Here, the first element in the array is the number of votes for the first option and the second element is a number of votes for the second option.

I have used the setJSON method to set the value as json in the blob.

await store.setJSON(key, [131, 231]);
Enter fullscreen mode Exit fullscreen mode

To get the value as JSON I have used the following code

await store.get(key, {
    type: "json",
});
Enter fullscreen mode Exit fullscreen mode

Netlify Functions

I have used the Netlify functions as API to fetch and add votes in the blob storage.

Top comments (4)

Collapse
 
philiphow profile image
Philip How

Haha - very well played. Good job.

Collapse
 
frikishaan profile image
Ishaan Sheikh

Thanks!

Collapse
 
jsha profile image
Julia Shlykova

I like that you blocked option 'other platform' :)

Collapse
 
frikishaan profile image
Ishaan Sheikh

Why choose others if you have Netlify 😉