Guest User

Untitled

a guest
Aug 26th, 2019
210
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function login()
  2. {
  3. let user = document.getElementById("username").value;
  4. let password = document.getElementById("password").value;
  5. get_aws_token(user,password)
  6. }
  7.  
  8. async function get_aws_token(user,password)
  9. {
  10. data = {'username': user, 'password':password };
  11. let myAuth = await fetch('https://74uszeihka.execute-api.ap-southeast-2.amazonaws.com/prod/auth',
  12. {
  13. method: 'PUT',
  14. headers: { 'content-Type': 'application/json'},
  15. credentials: 'same-origin',
  16. body: JSON.stringify(data),
  17. });
  18.  
  19. let myResponse = await myAuth.json();
  20.  
  21. document.getElementById("debugline").innerHTML = myResponse.status;
  22.  
  23. if (myResponse.status="success")
  24. {
  25. document.getElementById("outputtext").innerHTML = "Thanks, You have logged in successfully";
  26. }
  27. else if (myResponse.status="fail")
  28. {
  29. document.getElementById("outputtext").innerHTML = "Mmm. you did'nt get the right";
  30. }
  31. else
  32. {
  33. document.getElementById("outputtext").innerHTML = "Im sorry, I'm broken"
  34. }
  35.  
  36. }
RAW Paste Data