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
- unlike any other provider, your sites DN...
your nameservers dont work with a funny little CNAME error, which is a weird bug but thats what you get when you try to be the kitchen sink, funny errors.
- Weird Table Causes Console to break
I dont even know how this even happened looks like the $createdAt and , $id got switched? <@831428608895615056>
- I recently switched to TablesDb. When li...
olddb.list_documents( queries =[ Query.order_desc("timestamp"), Query.equal("isPosted",[False]) ] ) Above works fine and reruns documents But below don't return...