I'm trying to create a function that replicates a newly created user to a document in a collection(triggered by event)
I just get a Server Error occured trying to replicate the user: doge@doge.com in the logs.
TypeScript
import { Client, Databases, Permission, Role } from 'node-appwrite';
export default async ({ req, res, log, error }) => {
const client = new Client();
client
.setEndpoint(process.env.API_ENDPOINT)
.setProject(process.env.PROJECT_ID)
.setKey(process.env.APPWRITE_API_KEY);
const databases = new Databases(client);
const { $id, name, email } = req.body
try {
await databases.createDocument(process.env.DB_ID, process.env.COLLECTION_ID, $id, {
name,
email,
},
[
Permission.read(Role.any()),
Permission.update(Role.user($id))
])
} catch (e) {
error(`Error: ${e} occurred trying to replicate the user: ${email}.`)
return res.send("Error occurred");
}
return res.send("User created");
};
Any ideas?
TL;DR
Function is trying to duplicate a user into a document but encountering a server error. Check the API key and permissions. Make sure your endpoint, project ID, and database IDs are correct.Recommended threads
- Appwrite Cloud project is paused and nev...
Hi Appwrite Team & Community, I am facing a problem with one of my Appwrite Cloud projects which seems to be identical to the other cases of "paused projects" ...
- Timed out waiting for runtime error
execution id 6a3e0791978712d81ee0 im having issue with appwrite function runtime performance. even after 4gbram and cpu same function sometimes completes in a...
- Project auto-blocked after load testing ...
Hi team 👋 My project has been automatically blocked with the message: "Project is currently blocked — Access to this project is restricted. Contact support if...