infinity
infinity
PPrisma
Created by infinity on 7/23/2024 in #help-and-questions
Getting P2023 When getting params
This is where I want to render the data that I extract:
import React from 'react';
import Vendor from '@/components/frontend/onboardProfile/vendor';
import { getData } from '@/app/lib/getData';

export default async function Page({ params: { id } }) {
const user = await getData(`users/${id}`);
console.log(user);

return (
<div className='flex flex-col justify-center items-center'>
<h2>Hello {user.firstName}, welcome to our page</h2>
<Vendor user={user} />
</div>
);
}
import React from 'react';
import Vendor from '@/components/frontend/onboardProfile/vendor';
import { getData } from '@/app/lib/getData';

export default async function Page({ params: { id } }) {
const user = await getData(`users/${id}`);
console.log(user);

return (
<div className='flex flex-col justify-center items-center'>
<h2>Hello {user.firstName}, welcome to our page</h2>
<Vendor user={user} />
</div>
);
}
4 replies
PPrisma
Created by infinity on 7/23/2024 in #help-and-questions
Getting P2023 When getting params
This is my schema:
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}

model Products {
id String @id @default(auto()) @map("_id") @db.ObjectId
pid Int @unique
slug String @unique
productName String
brand String
imageUrl String[]
itemWeight Float
price Float
quantity Int
content String?
category String
apiCountry String?

user User @relation(fields: [userId], references: [id])
userId String @db.ObjectId

createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model VendorProfile {
id String @id @default(auto()) @map("_id") @db.ObjectId
firstName String
lastName String
email String
phoneNumber Int
apiCountry String?
userCountry String?

user User @relation(fields: [userId], references: [id])
userId String @db.ObjectId @unique

createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
}

enum UserRole {
ADMIN
CUSTOMER
VENDOR
STAFF
}

model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
firstName String
lastName String
email String @unique
emailVerified DateTime?
password String
phoneNumber Int
apiCountry String?
userCountry String

products Products[]
role UserRole @default(CUSTOMER)
vendorProfile VendorProfile?

createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}

model Products {
id String @id @default(auto()) @map("_id") @db.ObjectId
pid Int @unique
slug String @unique
productName String
brand String
imageUrl String[]
itemWeight Float
price Float
quantity Int
content String?
category String
apiCountry String?

user User @relation(fields: [userId], references: [id])
userId String @db.ObjectId

createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model VendorProfile {
id String @id @default(auto()) @map("_id") @db.ObjectId
firstName String
lastName String
email String
phoneNumber Int
apiCountry String?
userCountry String?

user User @relation(fields: [userId], references: [id])
userId String @db.ObjectId @unique

createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
}

enum UserRole {
ADMIN
CUSTOMER
VENDOR
STAFF
}

model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
firstName String
lastName String
email String @unique
emailVerified DateTime?
password String
phoneNumber Int
apiCountry String?
userCountry String

products Products[]
role UserRole @default(CUSTOMER)
vendorProfile VendorProfile?

createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
4 replies