javascript - ES6 API Fetch Login WebApp -


i'm asking if codes correct. i'm trying access post login api. should have response website api. problem on fetch function. doesn't post data api. says email , password required

function submitinfo(){  let form = document.forms["myform"];  let fd = new formdata(form);  let data = {};  (let [key, prop] of fd) {    data[key] = prop;  }  value = json.stringify(data, null, 2);  console.log(value);      fetch('http://example_website/api/login', {      method: 'post',      body: value  })    .then(data => data.json())  .then(data =>  { console.log(data) })   .catch((err) => {      console.error(err);  })    }
<body>      <form id="myform" name="myform">        <div>          <input type="text" id="email" name="email" value="example@gmail.com">        </div>        <div>          <input type="password" id="password" name="password" value="123">        </div>          <input type="button" value="submit!" onclick="submitinfo();">      </form>  </body>

you haven't added closing parentheses on fetch() function. have fetch(


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -