How can I receive an array of values in my POST endpoint?
I'm creating a dynamic questionnaires application in which I render questions in the front-end like this:
{% for q in questions %}
<label>{{q.question}}</label>
<input type="text" name="questions[{{q.id}}]">
{% endfor %}Then, I want to receive all values in my POST endpoint.
What I'm getting in my POST now is:
"questions": {
"2": "Text value",
"4": "Text value",
"7": "Text value"
}Is there a way how I can process this in my POST?
Or, better yet, is there a way to format my questions something like:
"questions": [
{
"id" : "2",
"value" : "Text value"
},
{
"id" : "4",
"value" : "Text value"
},
{
"id" : "7",
"value" : "Text value"
}
]Suggestions are welcome!
I'm creating a dynamic questionnaires application in which I render questions in the front-end like this:
{% for q in questions %}
<label>{{q.question}}</label>
<input type="text" name="questions[{{q.id}}]">
{% endfor %}Then, I want to receive all values in my POST endpoint.
What I'm getting in my POST now is:
"questions": {
"2": "Text value",
"4": "Text value",
"7": "Text value"
}Is there a way how I can process this in my POST?
Or, better yet, is there a way to format my questions something like:
"questions": [
{
"id" : "2",
"value" : "Text value"
},
{
"id" : "4",
"value" : "Text value"
},
{
"id" : "7",
"value" : "Text value"
}
]
Suggestions are welcome!
Login to reply