
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
- Issue with github oauth in firefox brows...
Hello Guys i have setup appwrite auth (Email Password, Google and Github). All auth methods works fine on the chrome based browsers but it has a strange issue w...
- Decentralisation
I had queries regarding decentralisation with self hosting, particularly with sites as a recent addition. Can we decentralise sites as in many cases we would li...
- Unable to read session cookie
Hi, when I am hitting Appwrite **/account** API. I am getting the user account details as expected in the response. However, with that API, Appwrite also adds a...
