TypeScript

by Alee

HTML

<div id="app"></div>
<button id="login">Login</button>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
  text-align: center;
}

TypeScript

var btnLogin = document.querySelector("#login")

btnLogin.onclick = function() {
	var data = 	{
    					email: "[email protected]"
						}

	var myInit = { 
								method: 'POST',
               	body: JSON.stringify(data),
             };
               
  fetch('https://reqres.in/api/register', myInit)
  .then(function(response) {
      console.log(response.status); // Will show you the status
      if (response.status !== 200) {
         //si no es 200
      }

      return response.json();
  })
  .then(function(response) {
      console.log(response);
  });
}