I am trying to send to and from objects through string via xhr API call. These objects are defined as follows:
(I've even wrapped properties in double quotes but in vain)
const to = {
        name: toName,
        address_line1: toAddres_line1,
        address_city: toCity,
        address_state: toState,
        address_zip: toZip
    };
    const from = {
        name : fromName,
        address_line1 : fromAddres_line1,
        address_city : fromCity,
        address_state : fromState,
        address_zip : fromZip
    };
var data = "to={" + to + "}&from={" + from + "}&color=false";  
tried removing spaces between " + to + " to "+to+" but no luck
While sending the property values inside data variable it is not getting passed properly. Upon console.log(to); and console.log(from); it gives me the right declaration of the objects in console which is as to={[object Object]}
Following error is thrown upon sending data to server by ```:
{
    "error": {
        "message": "from address not found",
        "status_code": 404,
        "code": "not_found"
    }
}
I tried searching if I'm passing the objects in a wrong way but couldn't hit a luck now. So, I am unable to find what is exactly wrong in my code.