Hi! In my SvelteKit project, I have the following appwrite.js file:
import { Client, Databases, Account, Storage } from "appwrite";
const client = new Client();
client
.setEndpoint("https://cloud.appwrite.io/v1")
.setProject("<my id>"); // Replace with your project ID
export const account = new Account(client);
export const databases = new Databases(client);
export const storage = new Storage(client);
then in +page.svelte script i have (basically from tutorial):
import { storage } from "$lib/appwrite";
const upload = () => {
const promise = storage.createFile(
"files",
ID.unique(),
document.getElementById("uploader").files[0],
);
promise.then(
function (response) {
console.log(response); // Success
},
function (error) {
console.log(error); // Failure
},
);
};
But when i try to upload i get the following error: Uncaught ReferenceError: ID is not defined. Any ideas why? Probably I did something stupid
Looks like you're not importing ID from anywhere so it's undefined.
import { ID } from "appwrite" or import { ID } from "node-appwrite"
Thank you very much!
For some reason on the wbsite the ID isn't imported anywhere
[SOLVED] Uncaught ReferenceError: ID is not defined
Recommended threads
- How to handle ghost accounts created by ...
Appwrite create the account with the email and send an invitation link with a secret. I am able to accept the invitation and add the account as a member on the ...
- Re-connect site to domain verification f...
I have mistakenly deleted appwrite site without removing domain. Now I created same site and want to re-connect my domain. It gives this error while verify. How...
- SSR share session to client using custom...
Hi, so I was trying to get a hang of using SSR and using realtime updates in the same time which is done easiest if you have a custom domain in Appwrite and as ...