Currently, I am in the process of developing a poll application that utilizes both Django and React. My approach involves using the fetch API to send POST requests to my Django server and receive detailed information in return for further processing. For all GET and POST operations on the front end, I rely on the fetch API to handle them seamlessly. Below is a snippet of my form class implementation:
export default class VoteForm extends React.Component{
constructor(props){
super(props);
this.state = {subjects:[],choosen:"",new:false,message:''};
this.handleSelect = this.handleSelect.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.handleNewOption = this.handleNewOption.bind(this);
}
// Other methods within the class...
In addition to the client-side implementation, here is an excerpt from my Django view function:
@api_view(['GET','POST'])
def vote_or_not(request):
if request.method == 'GET':
return Response(data={'message':'Retrieving data'})
# Handling POST method for voting functionality...
Despite receiving a successful HTTP 200 status code upon posting data to the backend, I encountered issues with the response handling. The expected behaviors like alerts and console logs did not function as intended. This indicates a discrepancy in the communication flow that needs to be resolved.