Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda