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
- My account is blocked so please check an...
My account is blocked so please unblock my account because all the apps are closed due to which it is causing a lot of problems
- Applying free credits on Github Student ...
So this post is kind of related to my old post where i was charged 15usd by mistake. This happens when you are trying to apply free credits you got from somewh...
- Attributes Confusion
```import 'package:appwrite/models.dart'; class OrdersModel { String id, email, name, phone, status, user_id, address; int discount, total, created_at; L...