티스토리 뷰

728x90
var request = require('request');

var options = {
  uri: 'https://www.googleapis.com/urlshortener/v1/url',
  method: 'POST',
  json: {
    "longUrl": "http://www.google.com/"
  }
};

request(options, function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body.id) // Print the shortened url.
  }
});

 

[출처] https://stackoverflow.com/questions/8675688/send-content-type-application-json-post-with-node-js

728x90

'공부' 카테고리의 다른 글

[Presto] FROM UNIX TIME in Presto syntax  (0) 2019.07.28
[Postman] POST send to file  (0) 2019.07.28
[AWS] Trouble shooting  (0) 2019.07.28
[Spark] List<String> Encoders  (0) 2019.06.30
Concurrency (동시성)  (0) 2019.06.30
댓글