orion-muf / KHU-2017-2-Capstone2-RENEW

0 stars 0 forks source link

구조 재구성 #25

Open muf opened 6 years ago

muf commented 6 years ago
muf commented 6 years ago

CORS (CROSS DOMAIN REQUEST )

muf commented 6 years ago

POST redirect for API

muf commented 6 years ago

비동기 개빡친다..

https://proinlab.com/archives/1811

muf commented 6 years ago

POST in nodeJS

request.post( 'http://www.yoursite.com/formpage', { json: { key: 'value' } }, function (error, response, body) { if (!error && response.statusCode == 200) { console.log(body) } } );

muf commented 6 years ago

var http = require('http');

var options = { host: 'www.host.com', path: '/', port: '80', method: 'POST' };

callback = function(response) { var str = '' response.on('data', function (chunk) { str += chunk; });

response.on('end', function () { console.log(str); }); }

var req = http.request(options, callback); //This is the data we are posting, it needs to be a string or a buffer req.write("data"); req.end();

muf commented 6 years ago

var myJSONObject = { ... }; request({ url: "http://josiahchoi.com/myjson", method: "POST", json: true, // <--Very important!!! body: myJSONObject }, function (error, response, body){ console.log(response); });