Forum Discussion
Hi charlesssgraham,
You could accomplish this by creating a custom endpoint that makes the API call and returns the LiQL data, and then using jQuery/Ajax to call the endpoint in your component.
On a related note, rather than using the <script> tag, you'll want to leverage the liaAddScript FreeMarker directive instead to wrap your client-side code, as it is much safer and avoids timing issues on dependencies.
Hope this helps.
- charlesssgraham3 years agoContributor
jeffshurtliff Thanks for the reply! I'm a bit stuck on how to translate the following query into a custom endpoint:
"SELECT id, login, email, rank.name, rank.simple_criteria.role.id FROM users"
The example given in the docs is a bit simplistic.. Could you give me a pointer or two on how to convert the above LiQL? After the endpoint is constructed, do I call it between the <@liaAddScript> tags or do I pass it into a fetch( )?
Thanks!
- JavidH3 years agoKhoros Staff
charlesssgraham You can add your query ("SELECT id, login, email, rank.name, rank.simple_criteria.role.id FROM users") to a custom component in studio using the below API V2:
<#assign query = restadmin("2.0","/search?q=" + "SELECT id, login, email, rank.name, rank.simple_criteria.role.id FROM users"?url).data.items/> <#list query as q> ${q.id} ${q.login} ${q.email} ${q.rank.name} <#if q.rank.simple_criteria.role?? && q.rank.simple_criteria.role.id??> ${q.rank.simple_criteria.role.id} </#if>, </#list>
Then you can add this custom component to your desired page in your community in studio.
Hope this helps.
- charlesssgraham3 years agoContributor
This absolutely helps! Thank you for your reply!
Related Content
- 2 years ago
- 2 years ago
- 4 years ago
- 3 years ago