Skip to content

Instantly share code, notes, and snippets.

@yamikuronue
Created December 1, 2015 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yamikuronue/9c77a3f7b3fce652e293 to your computer and use it in GitHub Desktop.
Save yamikuronue/9c77a3f7b3fce652e293 to your computer and use it in GitHub Desktop.
const req = http.request({
host: 'localhost',
port: '8080',
path: '/api/game/1111',
method: 'PUT'
});
req.write(JSON.stringify(formData) + "\n");
req.end();
@AccaliaDeElementia
Copy link

i think it's missing headers...

http.request is not very smart....

var postData = querystring.stringify({
  'msg' : 'Hello World!'
});

var options = {
  hostname: 'www.google.com',
  port: 80,
  path: '/upload',
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Content-Length': postData.length
  }
};
// write data to request body
req.write(postData);
req.end();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment