Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Do not send parameters with undefined to body #719

Open
gewisser opened this issue Jan 27, 2019 · 1 comment
Open

Do not send parameters with undefined to body #719

gewisser opened this issue Jan 27, 2019 · 1 comment

Comments

@gewisser
Copy link

src\url\index.js:58

/**
 * Encodes a Url parameter string.
 *
 * @param {Object} obj
 */

Url.params = function (obj) {

    var params = [], escape = encodeURIComponent;

    params.add = function (key, value) {

        if (isFunction(value)) {
            value = value();
        }

        if (value === null) {
            value = '';
        }

        this.push(escape(key) + '=' + escape(value));
    };

    serialize(params, obj);

    return params.join('&').replace(/%20/g, '+');
};

Vue.http.options.emulateJSON = true;

It is a little uncomfortable when value equals undefined. A line is sent to the backend:

What is Expected?

body = param=1

What is actually happening?

body = param=1&param2=undefined&param3=undefined

@youngkaneda
Copy link

I could work on this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants