Two of my projects are blocked when using functions
Code :
import { Client, Account ,Databases} from 'node-appwrite';
// This Appwrite function will be executed every time your function is triggered export default async ({ req, res, log, error }) => { if (req.method === 'OPTIONS') { return res.send('', 204, { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', 'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Appwrite-Key' }); } // Initialize the Appwrite client const client = new Client() .setEndpoint("https://6799b7db75f3f1251f5f.appwrite.global/v1") .setProject("6798f12500186de1e61d") .setKey(process.env.API_KEY);
// Initialize the Databases service const databases = new Databases(client);
const databaseId = "6798f1b2001d31742ec7"; const collectionId = "6798f1b9001f01d4c0c3";
try { // Fetch all documents from the specified collection const documentList = await databases.listDocuments(databaseId, collectionId);
return res.json({
success: true,
documents: documentList.documents,
}, 200, {
'Access-Control-Allow-Origin': '*',
});
} catch (err) {
// Return the error with appropriate CORS headers
return res.json({
success: false,
error: err.message,
}, 500, {
'Access-Control-Allow-Origin': '*',
});
} };
Recommended threads
- Unknown attribute type: varchar / text
Since the `string` type is deprecated I tried using `varchar` and `text` in some newer tables, but when running `appwrite pull tables && appwrite types ./src/li...
- I'm experiencing a critical bug on Appwr...
Hey <@870607367597850624> team / support 👋 I'm experiencing a critical bug on Appwrite Cloud that's blocking my production Flutter app. I've already filed GitH...
- Bug: TOTP MFA verification always fails ...
*Bug: TOTP MFA verify always returns `user_invalid_token` (Cloud 1.8.1, Frankfurt)** Project ID: `68dd48440003e537d849` SDK: `appwrite@18.2.0` (also tested wit...