-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,34 @@ | ||
const script = document.createElement('script'); | ||
script.src = 'https://cdn.jsdelivr.net/npm/[email protected]'; | ||
|
||
script.onload=()=>{ | ||
|
||
const client = new Appwrite.Client() | ||
.setEndpoint('https://cloud.appwrite.io/v1') | ||
.setProject('67609b010021900fc6e6') | ||
script.onload = async () => { | ||
const client = new Appwrite.Client() | ||
.setEndpoint('https://cloud.appwrite.io/v1') // Your Appwrite endpoint | ||
.setProject('67609b010021900fc6e6'); // Your Project ID | ||
|
||
const functions = new Appwrite.Functions(client); | ||
const account = new Appwrite.Account(client); | ||
|
||
const functions = new Appwrite.Functions(client) | ||
const account = new Appwrite.Account(client) | ||
const sessionId = localStorage.getItem("session") | ||
console.log(sessionId) | ||
const session = account.getSession(sessionId) | ||
const result = functions.createExecution("loginPoints") | ||
// Retrieve session ID from localStorage | ||
const sessionId = localStorage.getItem("session"); | ||
console.log("Session ID:", sessionId); | ||
|
||
if (!sessionId) { | ||
console.error("No session ID found. User might not be logged in."); | ||
return; | ||
} | ||
|
||
console.log(result) | ||
try { | ||
// Validate the session | ||
const session = await account.getSession(sessionId); | ||
console.log("Session details:", session); | ||
|
||
// Execute the function | ||
const result = await functions.createExecution("loginPoints"); | ||
console.log("Function execution result:", result); | ||
} catch (error) { | ||
console.error("Error occurred:", error); | ||
} | ||
}; | ||
|
||
document.head.appendChild(script); |