Advertisement
Guest User

Untitled

a guest
Oct 11th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. fetch('http://localhost:8080/login', {
  2. method: 'POST',
  3. mode:'cors',
  4. headers: {
  5. 'Accept': 'application/json',
  6. 'Content-Type': 'application/json'
  7. },
  8. body: JSON.stringify({
  9. username: this.state.username,
  10. password: this.state.password
  11. })
  12. });
  13.  
  14. var responseHeaders = {
  15. "access-control-allow-origin": "*",
  16. "access-control-allow-methods": "GET, POST, PUT, DELETE, OPTIONS",
  17. "access-control-allow-headers": "content-type, accept",
  18. "access-control-max-age": 10,
  19. "Content-Type": "application/json"
  20. };
  21.  
  22. app.post('/login', function(req, res, next) {
  23. if (req.method == "OPTIONS") {
  24. res.writeHead(statusCode, responseHeaders);
  25. res.end();
  26. }
  27. console.log("hello");
  28. ...
  29.  
  30. OPTIONS /login 200 8.570 ms - 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement