POST /api/poll
Name | Type | Notes |
---|---|---|
question |
string | Required |
options |
array | Required. Must contain at least two elements |
{
"question": "What is the best editor?",
"options": [
"Vim",
"Emacs"
]
}
If the poll was successfully created:
Status 201
{
"createdPollId": 1
}
If something wrong:
Status 500
{
"message": "An internal server error occured"
}
GET /api/poll/:pollId
If the poll was found:
Status 200
{
"question": "What video should I make next?",
"options": [
{
"pollOptionId": 1,
"text": "Advanced React",
"votes": 0
},
{
"pollOptionId": 2,
"text": "Arrow Functions Tutorial",
"votes": 0
},
{
"pollOptionId": 3,
"text": "Arch Linux Tutorial",
"votes": 0
}
]
}
If the poll cannot be found:
Status 404
If something wrong:
Status 500
{
"message": "An internal server error occured"
}
POST /api/vote
Name | Type | Notes |
---|---|---|
pollOptionId |
number | Required. |
If vote was successfully created:
Status 201
{
"pollOptionId": 1
}
If user has already voted on poll:
Status 400
{
"message": "You've already voted on this poll."
}
If something wrong:
Status 500
{
"message": "An internal server error occured"
}