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

175
Vistas
Javascript error: expected a string but got a object

I'm working with a third party affiliate program provider called Rewardful and trying to integrate them with my website. I know I have integrated them correctly as when I put into the console: Rewardful.affiliate it properly outputs the JSON response which is of the form:

{
  id: "b533bfca-7c70-4dec-9691-e136a8d9a26c",
  name: "James Bond",
  first_name: "James",
  last_name: "Bond",
  token: "james007"
}

However, I am trying to save this information to my database using Rewardful's script:

var affiliate;
rewardful('ready', function() {
  if(Rewardful.affiliate) {
    affiliate = Rewardful.affiliate;
  }
});

but I keep getting the error shown in the console: Expected a string but got a object (original data: {"id": "b533bfca-7c70-4dec-9691-e136a8d9a26c", "name": ... which is the same as the above except its getting returned in the form which starts with original data.

How do I extract the actual json response from this object? I have tried Object.entries(Rewardful.affiliate)[0] but that gives me the same error but strips out name, last_name, first_name and token.

Any help would be much appreciated. Thanks

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