Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. var http = require('http')
  2. const querystring = require('querystring')
  3.  
  4. var data = querystring.stringify({
  5. login: "login",
  6. password: "password"
  7. })
  8.  
  9. var options = {
  10. host: 'localhost',
  11. port: 8080,
  12. path: '/auth/sign_in',
  13. method: 'POST',
  14. headers: {
  15. 'Content-Type': 'application/x-www-form-urlencoded',
  16. 'Content-Length': Buffer.byteLength(data),
  17. 'Connection': 'keep-alive'
  18. }
  19. }
  20.  
  21. var req = http.request(options, function (response) {
  22. console.log(`status: ${response.statusCode}`)
  23. console.log(`headers: ${JSON.stringify(response.headers)}`)
  24. response.setEncoding('utf8')
  25. response.on('data', (body) => {
  26. console.log(`body: ${body}`)
  27. })
  28. })
  29.  
  30. req.write(data)
  31.  
  32. req.end()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement