-
-
Save ivaravko/2553009 to your computer and use it in GitHub Desktop.
request post node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'), default_headers, site_root = 'http://localhost:3000';; | |
default_headers = { | |
'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20100101 Firefox/7.0.1', | |
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', | |
'Accept-Language': 'en-us,en;q=0.5', | |
'Accept-Encoding': 'gzip, deflate', | |
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', | |
// 'Connection': 'keep-alive', | |
'Cache-Control': 'max-age=0' | |
}; | |
request({ | |
url: site_root + '/login', | |
headers: default_headers, | |
method: 'POST', | |
body: JSON.stringify({ user:'my_user', password:'my_pass' }) | |
}, function (err, res, body) { | |
if (!err && res.statusCode == 200) { | |
console.log(body); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment