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
- OIDC not working on Appwrite cloud
tl;dr: same project settings, same OIDC credentials. Auth works on self hosted but not in cloud. I have a project in my self hosted instance with a single web ...
- Create file is listing files instead of ...
This is a bit strange but, I cannot create files from within a funcion. I have tested with latest SDKs versions of node and python, both instead of creating the...
- Google OAuth2 is not working
the Google OAuth2 is working perfectly in localhost, but when I bring it to production that means real domain, then when I clicked button signin nothing happene...