Created
June 20, 2017 23:17
-
-
Save nazrdogan/7277b90d7499870fe6db5e247f54e9c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 data={ foo:"bar"}; | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
console.log("OK"); | |
} | |
}; | |
xhttp.open("POST", "http://localhost:8080", true); | |
xhttp.setRequestHeader("Content-type", "application/json"); | |
xhttp.send(JSON.stringify(data)); |
This file contains hidden or 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 http = require('http'); | |
http.createServer(function (req, res) { | |
res.write('Hello World!'); | |
req.on('data', function (chunk) { | |
if (req.method == 'POST') { | |
console.log(chunk.toString()); | |
} | |
}); | |
res.end(); | |
}).listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment