0

I have been googling for this and only found this.

    let req = request({
        url: "http://localhost/api/v1/phone",
        method: 'POST',
        json: {
            param1: "abc",
            param2: "def"
        }
    }, function callback(error, response, body) {});

This doesn't work. The error is:

client.js:771 POST http://localhost/[object%20Object] 400 (Bad Request)

How to fix this? This fails with the same eror if I change it to request.post.

    let req = request.post({
        url: 'http://localhost/api/v1/phone'

    }, (error, response, body) =>{
        logger.log('test123.error', error);
        logger.log('test123.response', response);
        logger.log('test123.body', body);
    });

but apparently it doesn't work.

TrongBang
  • 923
  • 1
  • 12
  • 23
  • Possible duplicate of [POST data with request module on Node.JS](https://stackoverflow.com/questions/6432693/post-data-with-request-module-on-node-js) – Saeed Jun 06 '18 at 08:44
  • Sorry. Actually I found the answer. I'm not using npm request. I'm using Superagent. That's why the syntax doens't work. – TrongBang Jun 06 '18 at 09:28

0 Answers0