Browse Source

Fixed sample app

qdn-on-chain-data
CalDescent 2 years ago
parent
commit
2822d860d8
  1. 67
      Q-Apps.md

67
Q-Apps.md

@ -352,40 +352,43 @@ Here is a sample application to display the logged-in user's avatar:
<html> <html>
<head> <head>
<script> <script>
try { async function showAvatar() {
// Get QORT address of logged in account try {
let address = await qortalRequest({ // Get QORT address of logged in account
action: "GET_ACCOUNT_ADDRESS" let address = await qortalRequest({
}); action: "GET_ACCOUNT_ADDRESS"
console.log("address: " + address); });
console.log("address: " + address);
// Get names owned by this account
let names = await qortalRequest({
action: "GET_ACCOUNT_NAMES",
address: address
});
console.log("names: " + JSON.stringify(names));
if (names.size == 0) {
console.log("User has no registered names");
return;
}
// Download the avatar of the first registered name
let avatar = await qortalRequest({
action: "FETCH_QDN_RESOURCE",
name: names[0].name,
service: "THUMBNAIL",
identifier: "qortal_avatar"
});
console.log("avatar: " + JSON.stringify(avatar));
// Display the avatar image on the screen
document.getElementsById("avatar").src = "data:image/png;base64," + avatar;
} catch(e) { // Get names owned by this account
console.log("Error: " + JSON.stringify(e)); let names = await qortalRequest({
action: "GET_ACCOUNT_NAMES",
address: address
});
console.log("names: " + JSON.stringify(names));
if (names.size == 0) {
console.log("User has no registered names");
return;
}
// Download the avatar of the first registered name
let avatar = await qortalRequest({
action: "FETCH_QDN_RESOURCE",
name: names[0].name,
service: "THUMBNAIL",
identifier: "qortal_avatar"
});
console.log("avatar: " + JSON.stringify(avatar));
// Display the avatar image on the screen
document.getElementsById("avatar").src = "data:image/png;base64," + avatar;
} catch(e) {
console.log("Error: " + JSON.stringify(e));
}
} }
showAvatar();
</script> </script>
</head> </head>
<body> <body>

Loading…
Cancel
Save