D
D
Danil Andreev2020-12-04 19:19:03
React
Danil Andreev, 2020-12-04 19:19:03

Why can there be a disconnection on request?

Good day. There is the following situation, a POST request is made to a certain address, if the request is made through Postman, then it is quietly processed without errors, in the case when this request is generated through my React application, the request is processed, but an error about disconnection also occurs. What could be the reason for this disconnection and how can I fix it?

Example of a request in Postman:
5fca611f336e4318002529.png

A function in React that executes a request:

onSubmit = () => {



  var data = {
      startDate: this.state.startDate + "T00:00:00.000000Z",
      endDate: this.state.endDate + "T00:00:00.000000Z",
      balance: parseInt(this.state.balance),
      number: parseInt(this.state.number)
  }


  const axiosConfig = {
      headers: {
          'Authorization': 'Bearer ' + localStorage.getItem('AccessToken'),
          'Content-Type': 'application/json',

      }
  }
  Axios.post('http://127.0.0.1:8000/card/', JSON.stringify(data), axiosConfig)
  .then(response => {
    console.log("GOOD");
  })
}


The error that occurs when requesting through React:
{'startDate': '2020-12-04T00:00:00.000000Z', 'endDate': '2030-12-31T00:00:00.000000Z', 'balance': 300, 'number': 998}
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 58951)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
    self.handle()
  File "/Users/ddev/Desktop/Python/something/venv/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
    self.handle_one_request()
  File "/Users/ddev/Desktop/Python/something/venv/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question