mirror of
https://github.com/Qortal/qortal.git
synced 2025-03-14 19:42:32 +00:00
Fixed sample app
This commit is contained in:
parent
5a052a4f67
commit
2822d860d8
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>
|
||||
<head>
|
||||
<script>
|
||||
try {
|
||||
// Get QORT address of logged in account
|
||||
let address = await qortalRequest({
|
||||
action: "GET_ACCOUNT_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;
|
||||
async function showAvatar() {
|
||||
try {
|
||||
// Get QORT address of logged in account
|
||||
let address = await qortalRequest({
|
||||
action: "GET_ACCOUNT_ADDRESS"
|
||||
});
|
||||
console.log("address: " + address);
|
||||
|
||||
} catch(e) {
|
||||
console.log("Error: " + JSON.stringify(e));
|
||||
// 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) {
|
||||
console.log("Error: " + JSON.stringify(e));
|
||||
}
|
||||
}
|
||||
showAvatar();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user