Next.js Discord

Discord Forum

account systeme

Unanswered
Checkered Giant posted this in #help-forum
Open in Discord
Avatar
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?
If someone can help me please, Thanks!

5 Replies

Avatar
Checkered GiantOP
what is the best method and how to do it securely?
I haven't used api for a long time and I don't understand it all.
Avatar
Tonkinese
The test api you have created, what does it look like?
Avatar
Checkered GiantOP
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}`)
    }
  
}
@Tonkinese
Avatar
Checkered GiantOP
So if someone know how to do please tell me!