How to use the traverse/hash.merge function in traverse

To help you get started, we’ve selected a few traverse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pkrumins / supermarket-cart / test / web.js View on Github external
self.cookies,
                function (c) { return c.value }
            ));
        }
        
        if (params.method == 'POST') {
            if (params.body && !headers['Content-Type']) {
                headers['Content-Type'] = 'application/x-www-form-urlencoded';
            }
            if (!Array.isArray(params.body) && typeof params.body == 'object') {
                params.body = qs.stringify(params.body);
            }
        }
        
        request(
            Hash.merge(params, {
                uri : uri + params.uri,
                headers : headers
            }),
            function (err, res, body) {
                var set = (res.headers || {})['set-cookie'] || [];
                if (typeof set == 'string') set = [set];
                set.forEach(function (raw) {
                    var key = raw.split(/=/)[0];
                    self.cookies[key] = {};
                    var vars = raw.replace(key, 'value').split(/;\s*/);
                    vars.forEach(function (kv) {
                        var k = kv.split(/=/)[0];
                        self.cookies[key][k] = kv.split(/=/)[1] || true;
                    });
                });
                cb(err, res, body);