POSTing with JSON using npm request

const formData = {
   client_id:     '0123456789abcdef', 
   client_secret: 'secret', 
   code:          'abcdef'
};

request.post(
  {
    url: 'https://todoist.com/oauth/access_token',
    form: formData
  },
  function (err, httpResponse, body) {
    console.log(err, body);
  }
);

Please try this code.


var url = 'http://xxxxx'
request({
  url : url,
  method :"POST",
  headers : {
    "content-type": "application/json",
  },
  body: {
    'id':1,
    'name':'xxxx'
  },
  json: true
},

it's working