aacerox / node-rest-client

REST API client from node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FORM-ENCODED serializer cannot handle array right

pinxue opened this issue · comments

  1. it treat array as usual object, say expecting ['a','b','c'], got {0:'a', 1:'b', 2:'c'}
  2. it seems a 'this.' is missing:
    https://github.com/aacerox/node-rest-client/blob/master/lib/nrc-serializer-manager.js#L159
    [this.]serialize(propertyValue, parsedProperty)
  3. callback undefined is not checked:
    https://github.com/aacerox/node-rest-client/blob/master/lib/nrc-serializer-manager.js#L169
    if(serializedCallback) serializedCallback(data);

Agree with @pinxue!

I can do a PR if there is somebody who can review.

I am not able to send a FORM-ENCODED request. While handling the request at the server end it throws
BadRequestError: content-type missing boundary

Request is :

const _ARGS = {
    data: {},
    headers: {
        "Content-Type": "application/json"
    },
    requestConfig: {
        timeout: 20000, //request timeout in milliseconds
        noDelay: true, //Enable/disable the Nagle algorithm
        keepAlive: true, //Enable/disable keep-alive functionalityidle socket.
        keepAliveDelay: 20000 //and optionally set the initial delay before the first keepalive probe is sent
    },
    responseConfig: {
        timeout: 20000 //response timeout
    }
};

_ARGS.data = rawReqBody;
                _ARGS.headers = {
                    "Content-Type": "multipart/form-data",
                };

let req = client.post(locationURL, _ARGS, function (data, response) {
                    // parsed response body as js object
                });