Javascript – Next js api call
using next js 13.4 I have created an api folder inside app folder iside that api folder i created one more folder named proxy and inside it i created route.js . while i am on home page i fetched it…
using next js 13.4 I have created an api folder inside app folder iside that api folder i created one more folder named proxy and inside it i created route.js . while i am on home page i fetched it…
I have a dynamic API route file for the POST request. Here is the code of that file: import { NextRequest, NextResponse } from "next/server"; import dbConnect from "@/lib/dbConnect"; import User from "@/models/User"; export async function POST(req: NextRequest, res: NextResponse)…
I'm learning nextjs using book "Building React Apps using server-side rendering" In this I'm building basic react app with index page link to about page. The project package.json - { "name": "my-next-app", "version": "1.0.0", "description": "", "main": "index.js", "scripts": {…
I have a MongoDB collection which contains some data created by users. I want to get exact time from createdAt filed. Please see the below image. See the createdAt timestamp for a data created on 2023-08-17 22:30:02. I'm building a…
Now I'm building a webpage that shows a ranking of items. I'm fetching datas with an external javascript file and using it by putting tag in nextjs page. The script uses the window variable, so I couldn't make it API…
While making a portfolio website with Next.js, this is some sort of error that I'm getting. I am using the latest version of Next.js which is next 13.4.16 and I am using app router in my project. this code is…
Hello I want to know how to use State Management(UseState, UseEffects) in Next JS using server-side rendering without using 'use client' at the top. And Will it decrease my page's performance using State Management(UseState, UseEffects) in client side? Can I…
I got this OnClick: const [open, setOpen] = useState(true); and onClick={() => setOpen(!open != true)} Aim is to "when open then close" and "when closed then remain closed". Above works for the second part but not the first. How to…
I'm trying to make a POST request with mongoose in NextJS. I have lib/dbConnect.js, models/User.js, app/new/route.ts. app/new/route.ts is the file for the page with the form, from where we will make a POST request. Here is my lib/dbConnect.js file: import…
I want to integrate rank math SEO tool API support for SEO. Following this tutorial, returns full HTML ready head with good metadata and others, but the problem is, how to render it into NextJS 13 head area? Nextjs 13…