How to use the traverse/hash.map 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
function process (params, cb) {
        var headers = Hash.copy(params.headers || {});
        
        if (Hash.size(self.cookies)) {
            headers.cookie = qs.stringify(Hash.map(
                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, {