Dakshie
I want to add labels to my user, but on the client side. how can I do it? (using nextjs)
TypeScript
import { NextResponse } from 'next/server';
import { account } from '../../../../lib/appwrite';
import { ID } from 'appwrite';
export async function POST(request: Request) {
try {
const { email, password, name } = await request.json();
console.log('Received registration data:', { email, name }); // Log received data (don't log password)
const user = await account.create(ID.unique(), email, password, name);
console.log('User created:', user);
await account.createVerification(`${process.env.NEXT_PUBLIC_APP_URL}/verify-email`);
console.log('Verification email sent');
const session = await account.createEmailPasswordSession(email, password);
console.log('Session created');
return NextResponse.json({ user, session });
} catch (error: unknown) {
console.error('Registration error:', error);
if (error instanceof Error) {
return NextResponse.json({ error: error.message || 'Registration failed' }, { status: 400 });
} else {
return NextResponse.json({ error: 'An unexpected error occurred' }, { status: 400 });
}
}
}```
TL;DR
Developers want to add labels to users on the client side using Next.js.
Unfortunately, it's not possible to add labels to users directly on the client side. The code provided focuses on user registration and verification processes, but it doesn't include any functionality for adding labels. Developers will need to implement this feature separately on the server side or through additional client-side logic. Joshi
You can't
Recommended threads
- Different appwrite IDs are getting expos...
File_URL_FORMAT= https://cloud.appwrite.io/v1/storage/buckets/[BUCKET_ID]/files/[FILE_ID]/preview?project=[PROJECT_ID] I'm trying to access files in my web app...
- Got message for auto payment of 15usd fo...
how did this happen? 1. i claimed my 50usd credits via jsm hackathon - https://hackathon.jsmastery.pro/ 2. it asked me which org. to apply the credits on, i se...
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...