Advertisement
xuio

Untitled

Apr 27th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. fetch('/api/v1/auth', {
  2. method: 'POST',
  3. headers: {
  4. 'cache-control': 'no-cache',
  5. 'content-type': 'application/x-www-form-urlencoded',
  6. },
  7. body: {
  8. username: "user",
  9. password: "pass"
  10. }
  11. })
  12.  
  13. var data = "username=test123&password=test123";
  14.  
  15. var xhr = new XMLHttpRequest();
  16.  
  17. xhr.open("POST", "/api/v1/auth");
  18. xhr.setRequestHeader("cache-control", "no-cache");
  19. xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
  20.  
  21. xhr.send(data);
  22.  
  23. xhr.addEventListener("readystatechange", function () {
  24. if (this.readyState === 4) {
  25. console.log(this.responseText);
  26. }
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement