Forum Discussion
MohammedF
Moderator
charlesssgraham If any of the comments were helpful, would you mind marking it as an accepted solution as it may help other users who may have similar requests?
charlesssgraham
3 years agoContributor
Done! One more question: is there an equivalent of logging query results to the console?
- JavidH3 years agoKhoros Staff
Create a custom endpoint (I'm naming it as q) in the studio:
<#assign query= restadmin("2.0","/search?q=" + "SELECT id, login, email, rank.name, rank.simple_criteria.role.id FROM users"?url).data.items/> ${query}
Create a custom component (naming it as component_q) in the studio:
<#assign communityId = community.id /> <#assign communityUrl = http.request.url /> <#assign lengthOfDomain = communityUrl?index_of("/") /> <#assign communityDomain = communityUrl?substring(0,lengthOfDomain) /> ${communityUrl} ${communityId} <@liaAddScript> ;(function($){ $.ajax({ type:"POST", url:'${communityDomain}/plugins/custom/qa/johndowden/q', contentType: 'application/json', success: function(res) { console.log(res); console.log("Results are listed"); }.bind(this), error: function(xhr, status, err) { console.error(xhr, status, err.toString()); console.log("Unable to view the results"); }.bind(this) }); })(LITHIUM.jQuery); </@liaAddScript>
Note: The URL must be your community URL of the endpoint in the studio.
When you add the component_q to any page in your community using studio, you can view the results in the console.
Hope this helps.
If this answers your question, would you please mark it as an accepted solution.
Related Content
- 2 years ago
- 2 years ago
- 4 years ago
- 3 years ago