#Getting a bad request for my server

9 messages · Page 1 of 1 (latest)

azure domeBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

limber dawn
#

DB CONFIG ```js
const {Pool} = require('pg')

const pool = new Pool({
user:"postgres",
password:"root",
port:5432,
host:"localhost",
database:"Gossip",
max:20,
connectionTimeoutMillis:2000,
idleTimeoutMillis:3000
})

export {pool}

#

UserProfile layout

#
import {pool} from "@/authconfig/dbconfig"
import { NextRequest, NextResponse } from "next/server";

export async function POST(request){
    try{
        const requestBody = await request.json()
        console.log(requestBody)
        const {id,name,address,phonenumber,gender,profileimage} = requestBody
        const queryInsert = `INSERT INTO PROFILE (id,name,address,phonenumber,gender,profile,image) VALUES ('${id}','${name}','${address}',${phonenumber},'${gender}','${profileimage}')`;
        const res = await new Promise((resolve, reject) => {
        pool.query(queryInsert,async (err,res) => {
            if(err){
                console.log(err);
                reject("Error inserting student")
                return NextResponse.json({message:"Error while creating account"},{status:400})
            }
            resolve(res)
        });
        
    })
    return NextResponse.json({message:"Account created successfully",success:true});
    }catch(error){
        console.log(error);
        return NextResponse.json({message:"Error while creating account"},{status:400})
    }

}

#

db code the route code basically

dapper root
#

Can you show some logs? What is the exact error you're getting

limber dawn
#

I fixed it no worries