Web Developer
New to AppWrite and first post here on Discord. Hello all.😀
I am having some issues understanding why my call to users.createTarget() fails in a function. (https://appwrite.io/docs/references/cloud/server-nodejs/users#createTarget).
I have the following code excerpt that works fine when being called from a node server app communicating with a self-hosted appwrite:
\\ \\ imports, client setup, other code \\ try { const result = await users.createTarget( deviceID, // userId - we use the device identifier as the user token targetID, // targetId - //Choose a custom ID or generate a random ID with ID.unique() 'push', // providerType apnsToken // identifier - the apns token //'', // providerId (optional) - will use the first push provider if not explictly set //'' // name (optional) ) return res.json({ "success" : "token associated with device" }) } catch(targetError) { error(`failed to create target ${targetError}`) return res.json({ "error": `unable to associate token` }, 400) }However, when I run this in a cloud hosted function, I get the error logged in the in the console: failed to create target TypeError: users.createTarget is not a function.
I am using the appwrite.io (cloud) to host the function.
The documentation online seems to suggest that this should be available in the cloud node-appwrite sdk?? Any suggestions?