Ribhnux / piranhax

Complete implementation package of Amazon Product Advertising API for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why replace with dot instead of array split?

oknoorap opened this issue · comments

_assignParameter(query) {
        // add parameter to query
        for (var y in this.Parameter) {
            let params = this.Parameter[y]
            if (Array.isArray(params)) {
                params = params.join(",")
            }

            // replace . with dot for backup
            y = _.replace(y, /\./ig, "dot")

            // add param name
            let paramName = _.startCase(y)
                .replace(/\s/gi, "")
                .replace(/Dot/ig, ".")
            query[paramName] = params
        }
        return query
    }

p.s: hehe gk online telegram wa

Some parameter such as Item.1.Quantity, Item.1.OfferlistingId, etc need that, some don't. If I split . to be array that would generalize all params, some param don't include . in it. It would be messefd up if I rejoin the array again. hehe

You can debug it with console.log if you want to know what I mean