Forum Discussion

cike's avatar
cike
Champion
11 years ago

NonStringException while making a REST API call

Hi,   within a custom component I make a REST API call to get all recent threads of my community. From this result I read the author informationen for every thread and make a second REST API call t...
  • nathan's avatar
    11 years ago

    That's the sort of error message you get when you try to reference a property of an object that doesn't exist, or isn't directly convertible to a string (e.g. another object).

     

    My guess is that URL property of author.ranking.display.right_image is not set. You can test this with code like this:

     <#if author.ranking.display.right_image?? && author.ranking.display.right_image.url??>
       <#assign imageUrl = author.ranking.display.right_image.url />
       console.log("${imageUrl}");
     </#if>

    I would also recommend putting looking at the data you're working with by putting the appropriate REST API url in your browser.