Next.js Discord

Discord Forum

Getting details from route.tsx

Unanswered
American Sable posted this in #help-forum
Open in Discord
Avatar
American SableOP
I am trying to create a sign up, login . I made a Post request through route handler. and I got the data.

now I want to send the data(request body) to another file so i can start updating the database.

how should I import/transfer the login and password to another file



export async function POST(request: Request ) {
    try {
    
       const data = await request.json();
  
    
      console.log("Received data:", data.email, data.password);
  
    
      return new Response(JSON.stringify({ message: 'Data received successfully!' }), {
        status: 200,
        headers: {
          'Content-Type': 'application/json',
        },
      });

   
    } catch (error) {
    
      return new Response(
        JSON.stringify({ error: 'Invalid data or something went wrong.' }),
        { status: 400 }
      );
    }


    

  }

0 Replies