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?
What version of the sdk are you using?
Aaah .. it may be that simple!! I used the starter template on both self-hosted server and cloud - but now realise that the starter template on the cloud uses an earlier version of node-appwrite.
haha, no worries. make sure to clear npm cache and pull the latest version. that should fix the issue.
thank you very much. will do!
please mark you issue as [SOLVED] once its resolved. If you encounter any other errors, feel free to create another thread or continue in this one.
Happy Appwriting :appwritecheers:.
[SOLVED]
hey π, could you please add [SOLVED] as the prefix to the post title so that its pretty visible outside the thread too π . thnx.
[solved] Create User Target unexpectedly fails.
[SOLVED] Create User Target unexpectedly fails.
Cheers. NOOB.
Recommended threads
- general_route_not_found - Auth Guide
If youβve just added a subdomain to your project, verified your DNS records, and confirmed your SSL certificate is working, but you're still hitting a `general_...
- Can't resume paused project
I have logged in in incognito, done the email verification and still get the invalid fingerprint error. What's the issue.
- Download appwrite Docs
Is there is a way to download appwrite Docs ? Because appwrite skill isn't enough to give the agent full understanding about how appwrite works (I noticed this ...