skip to Main Content

Mongodb – Delete nested object with Mongoose and Next js

My route is below: export async function GET() { await connectMongoDB(); const allCargoDetails = await CargoDetails.find(); return NextResponse.json({ allCargoDetails }); } export async function DELETE(request) { const id = request.nextUrl.searchParams.get("id"); await connectMongoDB(); await CargoDetails.findByIdAndDelete(id); return NextResponse.json({ message: "Detaily smazány" });…

VIEW QUESTION

Javascript – How to fetch in Server Components?

This is how I handle fetch now following the next’s document. https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#fetching-data-on-the-server-with-fetch async function getSuite(propertyId: string, suiteId: string) { const cookieStore = cookies(); const accessToken = cookieStore.get("accessToken"); const res = await fetch( `${process.env.NEXT_PUBLIC_API_BASE_URL}/suite`, { headers: { "X-Authorization": "Bearer " +…

VIEW QUESTION
Back To Top
Search