title: Using Fetch API to create a Login form
body: <p>So, I am making a login form and I have already implemented the fetch API</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const form = {
      email: document.querySelector("#signin-email"),
      password: document.querySelector("#signin-password"),
      submit: document.querySelector("#signin-btn-submit"),
      messages:document.getElementById("form-messages")
  };
  let button = form.submit.addEventListener("click", (e)=&gt; {
      e.preventDefault();
      const login = 'https://ffcc-app.herokuapp.com/user/login';
  
      fetch(login, {
            method: "POST",
            headers: {
              Accept: "application/json, text/plain, */*",
              "Content-Type": "application/json",
            },
            body: JSON.stringify({
              email: form.email.value,
              password: form.password.value,
            }),
          })
            .then((response) =&gt; response.json())
            .then((data) =&gt; console.log(data))
            .catch((err) =&gt; {
              console.log(err);
             });
      
      
  });</code></pre>
  </div>
  </div>
  </p>
  <p>I am also getting the desired output:
  <img src="https://i.stack.imgur.com/WJBh2.png" alt="This is my output" /></p>
  <p>The problem is I have to redirect to the main page when 'login successful' else I have to display a message saying 'user does not exist'. how should I do that? What else should I add to my code?</p>