공부

[NodeJS] request Content-Type `application/json`

승가비 2019. 7. 28. 18:13
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