Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

150
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda