Criffis
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
- 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...
- delete document problems
i don't know what's going on but i get an attribute "tournamentid" not found in the collection when i try to delet the document... but this is just the document...
- Attributes Confusion
```import 'package:appwrite/models.dart'; class OrdersModel { String id, email, name, phone, status, user_id, address; int discount, total, created_at; L...