Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const http = require('http');
- var options = {
- host: "jsonplaceholder.typicode.com",
- path: "/posts",
- method: "POST",
- }
- var req = http.request(options, function (res) {
- var responseString = "";
- res.on("data", function (data) {
- responseString += data;
- // save all the data from response
- });
- res.on("end", function () {
- console.log(responseString);
- // print to console when response ends
- });
- });
- req.on('error', (err) => {
- console.log('error:', err);
- })
- req.end();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement