Back

'Client' has no member 'setKey'

  • 0
  • Apple
  • Cloud
Drake
16 Aug, 2023, 00:43

what do you mean? what code?

TL;DR
Summary: The user is encountering an issue with the 'Client' class in their code. Other users explain that using the 'setKey()' method is unnecessary and should be removed. The solution is to not set the API key on the client side, and it is only needed for server-side API calls or Appwrite functions. The user should initialize the client in their code, and it is not necessary to have multiple instances of the 'Client' class. Tagging specific people is discouraged, and the user is reminded to read the documentation.
C09
16 Aug, 2023, 04:02

In the pictures

Drake
16 Aug, 2023, 04:04

Are you still asking about the setKey()?

safwan
16 Aug, 2023, 04:59

Your code looks like you're trying to initialize the client. Yiu can initialize the client anywhere in your code

safwan
16 Aug, 2023, 04:59

It's best to have just one instance of Client though

C09
16 Aug, 2023, 05:08

@Steven I am talking about this

safwan
16 Aug, 2023, 05:32

Please don't tag (@) people directly. Why do you need the API key?

safwan
16 Aug, 2023, 05:32

An API key is needed in Appwrite only when creating cloud functions.

D5
16 Aug, 2023, 07:55

I mean you should never try using an Appwrite API key client side because:

  • It's not needed
  • It's not possible in client side SDK's
  • That allows the one that has such key having unlimited access to the given scopes (bypassing permissions)
C09
16 Aug, 2023, 08:56

So where should the server side be?

D5
16 Aug, 2023, 09:10

For server side API like Appwrite functions then you set API key, but as said, never set API key client side

C09
16 Aug, 2023, 09:10

So in Appwrite?

D5
16 Aug, 2023, 09:11

If you use Appwrite with a custom server or in Appwrite functions, as said, just if you execute the code server-sided

D5
16 Aug, 2023, 09:12

In your case, just don't set API key and done

C09
16 Aug, 2023, 09:32

How about user?

D5
16 Aug, 2023, 09:39

User don't need API key

C09
16 Aug, 2023, 09:39

But how to fix it

D5
16 Aug, 2023, 09:40

Just remove .setKey line

D5
16 Aug, 2023, 09:42

As said, never use .setKey in your app

safwan
16 Aug, 2023, 09:50

@C09 have you read through the docs?

C09
16 Aug, 2023, 09:51

oh...where?

C09
16 Aug, 2023, 09:55

Sorry my friend just got me into this for a school project

safwan
16 Aug, 2023, 10:40
safwan
16 Aug, 2023, 10:40

Have a read through the docs and feel free to ask questions!

Drake
16 Aug, 2023, 16:02

andm ake sure you're using the apple sdk: https://github.com/appwrite/sdk-for-apple

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