в контроллере получить request.POST получаю пустой словарь:
                  
                  
                            var xhr = new XMLHttpRequest();
                  
                  
                            let json = JSON.stringify({
                  
                  
                              name: "John",
                  
                  
                              surname: "Smith",
                  
                  
                              csrfmiddlewaretoken: "{{ csrf_token }}"
                  
                  
                            });
                  
                  
                            xhr.open("POST", "{{ url('infly_todo:task_detail', kwargs={'pk': task.pk}) }}", true);
                  
                  
                            xhr.setRequestHeader('Content-Type', 'application/json');
                  
                  
                            xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
                  
                  
                            xhr.setRequestHeader('X-CSRFToken', '{{ csrf_token }}')
                  
                  
                            xhr.onload = function() {
                  
                  
                                if (xhr.status === 200) {
                  
                  
                                    console.log(JSON.parse(xhr.responseText));
                  
                  
                                }
                  
                  
                                else {
                  
                  
                                    console.log('Request failed.  Returned status of ' + xhr.status);
                  
                  
                                }
                  
                  
                            };
                  
                  
                            xhr.send(json);
                  
                  
                  Это проблема в запросе или это в бэке что-то не то?
                  
                  
                
а ты как его принимаешь на беке?
Обсуждают сегодня