Tell me how to make an HTTP POST request in node.js?
Submitted by: AdministratorThis gets a lot easier if you use the request library.
var request = require('request');
request.post(
'http://www.abcsite.com/formpage',
{ form: { key: 'value' } },
function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body)
}
}
);
Aside from providing a nice syntax it makes json requests easy, handles oauth signing (for twitter, etc.), can do multi-part forms (e.g. for uploading files) and streaming.
Submitted by: Administrator
var request = require('request');
request.post(
'http://www.abcsite.com/formpage',
{ form: { key: 'value' } },
function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body)
}
}
);
Aside from providing a nice syntax it makes json requests easy, handles oauth signing (for twitter, etc.), can do multi-part forms (e.g. for uploading files) and streaming.
Submitted by: Administrator
Read Online Node.js Job Interview Questions And Answers
Top Node.js Questions
☺ | Explain Node.js Architecture? |
☺ | How to extract POST data in node.js? |
☺ | What is Node.js? |
☺ | Do you know how to debug node.js applications? |
☺ | Do you know how to get POST query in express node.js? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |