Next.js Discord

Discord Forum

use nextjs to create a account systeme with sequelize

Unanswered
Checkered Giant posted this in #help-forum
Open in Discord
Checkered GiantOP
Heyy! i need to create a login/register systeme in my nextjs project, i allready make some api test ect, but i got some truble about how i need to call my api, as exemple when someone register do i need to use a body in my api to put the info to the api or du i use a slug api url?

I create one using the slug api named [id].js and i want to know if that better to use the api req.body (when i try use req.body thats dont work)
and my slug api test is :
import { NextApiRequest, NextApiResponse } from 'next'
import User from '../../../module/sequelize/model/User'
import { Sequelize } from 'sequelize'

export default async function handler(_req, res) {
    const { id } = _req.query
    try {

        await User.findOne({
        where: {
            [Sequelize.Op.or]: [{ id: `${id}` }],
        },
        }).then(x=>{
            if(x&&x.username){
                res.end(`${x.username}`)
            }else{
                res.end(`can't find`)
            }
        })

    } catch (error) {
        // Handle any errors that occur during the request
        res.end(`err : ${error}`)
    }
  
}


If someone can help me please, Thanks!

1 Reply

Holland Lop
could you also provide your git repositories