title: Passing in values to a JSON Post request
body: <p>My original issue was it was getting the value when the user clicked on the compose button but not the send button.</p>
  <p>I have now changed it to use a different new function when the user clicks send.  However, now it's not doing anything.</p>
  <p>Can someone tell me what I'm doing wrong? I used the onclick method in the HTML and then created the function on my Javascript page.</p>
  <p>HTML:</p>
  <pre><code>&lt;div id=&quot;compose-view&quot;&gt;
          &lt;h3&gt;New Email&lt;/h3&gt;
          &lt;form id=&quot;compose-form&quot;
          method=&quot;POST&quot;&gt;
              {% csrf_token %}
              &lt;div class=&quot;form-group&quot;&gt;
                  From: &lt;input disabled class=&quot;form-control&quot; value=&quot;{{ request.user.email }}&quot;&gt;
              &lt;/div&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                  To: &lt;input id=&quot;compose-recipients&quot; class=&quot;form-control&quot;&gt;
              &lt;/div&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                  &lt;input class=&quot;form-control&quot; id=&quot;compose-subject&quot; placeholder=&quot;Subject&quot;&gt;
              &lt;/div&gt;
              &lt;textarea class=&quot;form-control&quot; id=&quot;compose-body&quot; placeholder=&quot;Body&quot;&gt;&lt;/textarea&gt;
              &lt;input type=&quot;submit&quot; id=&quot;sendEmail&quot; class=&quot;btn btn-primary&quot;/&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  </code></pre>
  <p>JS:</p>
  <pre><code>const element = document.getElementById('sendEmail');
    element.addEventListener('click', function() {
      fetch('/emails', {
      method: 'POST',
      body: JSON.stringify({
        recipients: 'card51short@gmail.com',
        subject: &quot;buglets&quot;,
        body: 'Hes a fat one'
      })
    })
    .then(response =&gt; response.json())
    .then(result =&gt; {
        // Print result
        console.log(result);
    });
    });
  }
  </code></pre>