JSFiddle - React, Tailwind, and code Playground

JavaScript

function toQueryString (obj){
    var result =[];
    for(var i in obj){
        if(obj.hasOwnProperty(i)){
            if(typeof obj[i] === "object") result.push(toQueryString(obj[i]))
            else result.push(encodeURIComponent(i) + "=" + encodeURIComponent(obj[i]));
        }
    }
    return result.join("&");
}


console.log(toQueryString({abc:123,def:456,ghi:{k:555, l:666}}))