An example of how to use the CrowdfundHQ API from within your site
<script> | |
// Enable 'Sessions enabled' in Manage Site > Configuration > Settings > API | |
// Then use this script in Manage Site > Design > Pages or Scripts to fetch users | |
document.addEventListener('DOMContentLoaded', function(){ | |
// Define variables | |
var url = '/api/v1/user/list', result, list, user; | |
// Do ajax call using hq.js | |
hq.ajax(url, { | |
success: function(json) { | |
// Parse API response | |
result = JSON.parse(json); | |
// Parse list as JSON | |
list = result.data; | |
// Look up first entry | |
user = list[0]; | |
// Do something with user | |
console.log(user); | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment