
Hello everyone,
I'm learning appwrite function on self hosted And i have some errors
My github is connected, function is working, but I can't get Database from my project, I have this error :
{"error":"request to http://exemple.com/v1/databases/66fa79e3000646bbcd04/collections failed, reason: connect ECONNREFUSED 127.0.1.1:80"}
Can someone help me ?
Here is a code I tried : ` import { Client, Databases } from 'node-appwrite';
export default async ({ res, log, error }) => { try { // Initialisation du client Appwrite const client = new Client() .setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT) .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID) .setKey(process.env.APPWRITE_FUNCTION_API_KEY); console.log(process.env); const databases = new Databases(client);
// Vérifie que l'environnement fournit l'ID de la base
const databaseId = process.env.APPWRITE_FUNCTION_DATABASE_ID;
if (!databaseId) {
return res.json({ error: "Missing DATABASE_ID environment variable" }, 400);
}
log(`Fetching collections for database ID: ${databaseId}`);
// Récupère toutes les collections
const collectionsResponse = await databases.listCollections(databaseId);
const collections = collectionsResponse.collections.map(c => ({
id: c.$id,
name: c.name,
enabled: c.enabled,
documentCount: c.sum || 0
}));
log(`Found ${collections.length} collections`);
return res.json({
message: "Collections fetched successfully",
collections: collections
});
} catch (err) { error("Failed to fetch collections: " + err.message); return res.json({ error: err.message }, 500); } }; `
Is there a better way to allow a function to read/create/update document in Db/Collection ?
Thank you !
Recommended threads
- Getting `net::ERR_CERT_AUTHORITY_INVALID...
I've set up Appwrite via Coolify on my VPS, but all the Functions and Sites I deploy give a `net::ERR_CERT_AUTHORITY_INVALID` error. I am happy to provide whate...
- Cant view Storage File in Appwrite Conso...
If I set a token on a storage file using the appwrite function (createFileToken), I can no longer see the file in detail in the appwrite console. I get the erro...
- How can I upgrade to RC manually
Hello! I am self-hosting an Appwrite instance and ran into this issue https://github.com/appwrite/appwrite/issues/9906 I saw that the bug has already been fixe...
