BloodThermic
Why wont user.$id
export outside of the handleSubmit
function?
TypeScript
import loginimg from "$lib/assets/login.jpg";
import { Client, Account, ID } from "appwrite";
import { goto } from "$app/navigation";
import {PUBLIC_API_ENDPOINT, PUBLIC_PROJECT_ID} from '$env/static/public'
const client = new Client();
const account = new Account(client);
client
.setEndpoint(PUBLIC_API_ENDPOINT) // Your API Endpoint
.setProject(PUBLIC_PROJECT_ID) // Your project ID
let user;
async function handleSubmit() {
const formData = new FormData(event.target);
const name = formData.get("name");
const email = formData.get("email");
const password = formData.get("password");
user = await account.create(ID.unique(), email, password, name);
console.log(user.$id);
}```
TL;DR
The user.$id variable is not exporting outside of the handleSubmit function. The issue is likely due to scoping.
Solution:
To make the user.$id variable accessible outside of the handleSubmit function, declare it outside of the function scope. For example, declare it at the top level of the file before the handleSubmit function. Drake
What do you mean?
BloodThermic
[SOLVED] User.$id wont export out of function
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...