inviting npubs
This commit is contained in:
parent
9c90b75bc0
commit
56121342d6
6 changed files with 76 additions and 2 deletions
28
src/public/javascript/invite.js
Normal file
28
src/public/javascript/invite.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
function acceptInvite() {
|
||||
const npub = window.nostr.getPublicKey();
|
||||
console.log("Npub is" + npub);
|
||||
|
||||
npub.then(async function (npub) {
|
||||
try {
|
||||
const response = await fetch('/api/invited-npub', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
"npub": npub
|
||||
})
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
console.log('invited-npub record created successfully:', data);
|
||||
} else {
|
||||
const error = await response.json();
|
||||
console.error('Failed to create invited-npub record:', error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('An error occurred:', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue