Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
Passing object in a string using Javascript

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!