Rank 1: Thread
I have tried this on multiple machines with a fresh install of AppWrite:
Based on example on https://appwrite.io/docs/server/databases?sdk=nodejs-default#databasesCreate
const sdk = require("node-appwrite");
module.exports = async function (req, res) { const client = new sdk.Client(); const database = new sdk.Databases(client);
if ( !req.variables['APPWRITE_FUNCTION_ENDPOINT'] || !req.variables['APPWRITE_FUNCTION_API_KEY'] ) { // Changed 'console.warn()' to 'console.log()' or else I would never see this message. console.log("Environment variables are not set. Function cannot use Appwrite SDK."); } else { client .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) .setSelfSigned(true); }
const promise = database.create(sdk.ID.unique(), 'test'); // This part does not output anything :( (see attached images) promise.then(function (response) { console.log(response); }, function (error) { console.log(error); });
res.json({ areDevelopersAwesome: true, });};Am I missing something?