Forum Discussion

frardouin's avatar
7 years ago

Get kudoed messages by user

Hi everyone, I'm trying to display all the messages kudoed by a user in his profile page. This is currently not working in my component. I think the problem come maybe from the last query in the lis...
  • VikasB's avatar
    VikasB
    7 years ago

    frardouin

    As 2nd APi also returning the array so we must put it in list also. Here is the corrected version. 

    <#assign currentUserid = page.context.user???then(page.context.user.id, user.id) />
    <#assign kudoedMessages = restadmin("2.0", "/search?q=" + ("SELECT * FROM kudos WHERE user.id = '${currentUserid}'")?url).data.items![] />
    
    <#list kudoedMessages as kudoedMessage>
        <#assign messages= rest("2.0","/search?q=" + "SELECT * FROM messages WHERE id='${kudoedMessage.message.id}'"?url).data.items![] />
        <#list messages as message>
    	    <p>${message.id}</p>
    	    <p>${message.subject}</p>
    	    <p>${message.post_time?date}</p>
    	    <p>${message.author.login}</p>
        </#list>
    </#list>