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
- Cannot Send Email
for some reason i keep getting this error when i try to send a test email with appwrite messaging... "Failed sending to target MYEMAIL1234@gmail.com with error:...
- I/flutter (24410): AuthError: HandshakeE...
I/flutter (24410): AuthError: HandshakeException: Handshake error in client (OS Error: I/flutter (24410): TLSV1_ALERT_UNRECOGNIZED_NAME(tls_record.cc:592))
- Creating functions for FCM Token based M...
I have previously setup cloud run functions on my firebase project, which im looking to migrate to appwrite. I need help on getting started, and getting me thro...