Advertisement
mikeymop

Untitled

Sep 23rd, 2019
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. function sendToMid(username, password) {
  2.  
  3. console.log(JSON.stringify({ucid: username, pass: password}))
  4. const form = document.getElementById('login-form');
  5. console.log("send data");
  6.  
  7. fetch('my apis url', {
  8. method: 'post',
  9. //mode: "same-origin",
  10. //credentials: "same-origin",
  11. headers: {
  12. //'Access-Control-Allow-Origin': 'https://web.njit.edu/~md537/mid.php',
  13. 'Accept': 'application/json',// text/plain, */*',
  14. 'Content-Type': 'application/json'
  15. },
  16. body: JSON.stringify({ucid: username, pass: password})
  17. }).then(function(response) {
  18. // console.log(response.json());
  19. return response.json();
  20. }).then(function(jsonresponse) {
  21. console.log(jsonresponse);
  22. console.log("thats all folks");
  23. console.log(jsonresponse.json());
  24.  
  25. });
  26. console.log("finished executing");
  27. }//sendToMid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement