Monday 29 October 2018

How can I pass data from the frontend to the server?

Context: using Pug, making a Peer Review thing for school.When a student begins to take a review, we pass pug the questions and the assignment ID and they fill in the answers and send them back. I've got the first part down, but two things:How does the frontend track the assignment ID? Should I make it part of the submission URL or something? ie POST /assignment/:id/submit when the review is doneWhat's the best way to pass answers back? I feel like form-url-encoded is an odd choice for something like a review with free response questions. JSON would be nice, but how do I get the front end to send it all back as JSON? My first instinct is to have a submit action script that just gets references to each input field and constructs a JSON object and sends it back. Seems tedious, is there a better way?

Submitted October 29, 2018 at 09:52PM by ThePantsThief

No comments:

Post a Comment