0

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

user2382321
  • 105
  • 1
  • 10

0 Answers0