Back

Node.js sdk createBucket error

  • 0
  • Web
  • Storage
iwanjones412
8 May, 2024, 19:45

Hi, hoping to get a bit of help on an issue if possible. I'm currently trying to create a bucket using the the createBucket node.js sdk. I'm getting this error - return await this.client.call('post', apiPath, { ^ TypeError: Cannot read properties of undefined (reading 'call').

The client value is set correctly, with the endpoint, project id and key. within the same file I am creating users and teams. This is what the code looks like. const client = new sdk.Client(); const storage = new sdk.Storage(); client .setEndpoint(this.endpointKey) .setProject(this.projectKey) .setKey(this.key); console.log(client); console.log('create bucket process'); const result = await storage.createBucket( '12345', // bucketId 'testBucket', // name // [ // sdk.Permission.create(sdk.Role.team(this.teamId)), // sdk.Permission.read(sdk.Role.team(this.teamId)), // sdk.Permission.update(sdk.Role.team(this.teamId, "admin")), // sdk.Permission.delete(sdk.Role.team(this.teamId, "admin")) // ], ["read('any)"], true, // fileSecurity (optional) false, // enabled (optional) 30, // maximumFileSize (optional) [], // allowedFileExtensions (optional) sdk.None, // compression (optional) false, // encryption (optional) false // antivirus (optional) ) console.log('create bukcet result'); console.log(result);

Any help would be extremely appreciate and thank you in advance

TL;DR
Developers are getting a 'Cannot read properties of undefined' error when trying to create a bucket using the Node.js SDK. The issue seems to be with the way the SDK client is being set up. Ensure the client is correctly initialized before calling the createBucket function. Check that the SDK client is properly configured with the endpoint, project ID, and key. Double-check the client setup and try to call functions only after ensuring the client is correctly initialized.
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