title: how do I send post request with fetchAPI
body: <p>I have a simple 'username' , 'password' form in index.html, the thing is I would like to send a post request to 'login.php' (which only echoing 'hello' for the moment), but all examples about fetchAPI that I found are related to JSON. In one of my projects, I would like to post username to something like 'usercheck.php' and check for available username and write 'This username is available' '...is not available' by using fetchAPI. Im probably missing a syntax...<br>
  So the problem is im keep getting <strong>405 (Method not allowed)</strong></p>
  <p><strong>main.js</strong></p>
  <pre><code>const myForm = document.querySelector('#myForm');
  
  myForm.addEventListener('submit', (e) =&gt; {
  
  e.preventDefault();
  
  const username = document.querySelector('#inp_username').value;
  //const password = document.querySelector('#inp_password').value;
  
  fetch('login.php' , {
      method: 'POST', 
      body: {username: username}
  })
  .then((res) =&gt; res.text())
  .then((data) =&gt; {
      console.log(data);
  
  })
  })
  </code></pre>
  <p><strong>and my login.php</strong></p>
  <pre><code>&lt;?php
  
  echo 'hello';
  
  ?&gt;
  </code></pre>