Back

Databases is not a valid constructor functions

  • 0
  • Web
elnur
25 Oct, 2023, 10:36

`import { Client } from 'node-appwrite';

export default async ({ req, res, log, error }) => { // Initialize Appwrite const client = new Client() .setEndpoint('api.example.com') .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID) .setKey(process.env.APPWRITE_API_KEY);

// Init database const database = new client.Databases(client)`

error: TypeError: client.Databases is not a constructor at Module.default (file:///usr/local/server/src/function/src/main.js:28:20) at execute (/usr/local/server/src/server.js:141:48) at async /usr/local/server/src/server.js:158:13

TL;DR
The error message "Databases is not a valid constructor function" is shown when trying to create a new database object. The code provided attempts to create a database object using the `client.Databases` constructor, but it is not recognized. The solution to this issue is to use the correct constructor for creating a new database object. Here's the corrected code: ``` // Initialize Appwrite const client = new Client() .setEndpoint('api.example.com') .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID) .setKey(process.env.APPWRITE_API_KEY); // Init database const database = new client.Database
elnur
25 Oct, 2023, 10:37

Function was made with the starter template.

elnur
25 Oct, 2023, 10:39

Databases is not a valid constructor functions

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more