Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

287
Vistas
API resolved without sending a response Next js

I am building a project using next js and firebase. I use the API routes that next offers for signup and login. The code registers the users in firebase but I keep getting this warning: API resolved without sending a response for /api/auth/signup, this may result in stalled requests. This is the code in my /api/auth/signup/. Hopefully, you can help me fix it.

export default function signup(req, res){
if(req.method === 'POST'){
    const {body: {email, password, displayName}} = req;
    createUserWithEmailAndPassword(auth, email, password)
    .then((userCredential) => {
        updateProfile(userCredential.user, {displayName: displayName})
        const {uid, email, phoneNumber, photoURL} = userCredential.user;
        addDoc(collection(db, "users"), {
            id: uid,
            displayName: displayName,
            email: email,
            phoneNumber: phoneNumber,
            photoURL: photoURL,
        });
        res.json(userCredential.user)
    })
    .catch((err) => {
        console.log(err.code);
        console.log(err.message);
    });

} else {res.json({"error": "Route only available for POST method"})}

}

7 months ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.