Questions tagged [next-api]
24 questions
3
votes
2 answers
req.body is undefined when fetching method delete in Next.js
I really don't know why, but when I try to fetch data and put it in the body of my response, it says undefined (in the console). I have almost 2 identical components. One uses a POST method and returns a populated body, the other uses a DELETE…

huzaks
- 33
- 4
2
votes
0 answers
POST request to Sanity CMS using Next.js API & next-connect resulting in 500 ERROR
I am having trouble making a POST request of user info on a register form to the Sanity CMS.I am using Next.js & next-connect. I am getting a 500 error when making the request.
Here is a snippet of code from the register.js front end page:
const…

Calathea
- 21
- 2
2
votes
2 answers
How to start the graphql server in new version of next js 13.2 api route?
Unable to start the server in next js 13.2.
import { ApolloServer } from '@apollo/server';
import { startServerAndCreateNextHandler } from '@as-integrations/next';
const resolvers = {
Query: {
hello: () => 'world',
},
};
const typeDefs =…

Raja Jayaraman
- 23
- 3
1
vote
1 answer
Next-connect error : unable to use next-connect for routing in my next.js project with javascript
My next version is 13.4.5 (latest)
My next-connect version is 1.0.0 (latest)
In pages>api>auth>signup.js :
import { createRouter } from "next-connect"
const handler = createRouter()
handler.post(async (req, res) => {
res.send("Welcome from the…

Riyan Ali
- 11
- 2
1
vote
0 answers
How to use formidable with NextJS 13 API for image uploading and solve request error?
I'm trying to add image uploading functionality to my app.
I'm using NextJS 13.4.4 and formidable@v3. Whenever I upload an image I get this error:
error TypeError: req.on is not a function
at IncomingForm.parse…

abdooumeh
- 11
- 2
1
vote
1 answer
Serve static javascript file from nextjs api
I need a route in website build with nextjs that sends javascript that can be used on different website to do some things.
I created new file in pages/api, let's call it sendTest.ts so it's location is pages/api/sendTest.ts. In the same folder I…

Neidd
- 61
- 6
0
votes
0 answers
Can't submit a form on react using next and prisma because of an error 500
I have a form that is suppose to sent comment on a blog article, i receive an error 500 and i don't understand why.
I tried to change the route that i call but i'm not sure it comes from that.
Maybe shoul i mentionned somewhere else the postId? i'm…

Caro
- 1
- 1
0
votes
0 answers
How to disconnect redis client before new client to be connected on Next API
I had initialised a client in this way, and everytime redisManager is called it creates a new client to be connected o the server.
import { createClient } from "redis"
const isConnected : {
status?: boolean
} = {
};
export const client =…
0
votes
0 answers
nextJS 13 API is not giving request URL query data
I am getting data from the Vercel database using Drizzele as ORM in NextJS 13 API routes but the issue is I am getting cookies value user_id from the user that sends a request to my GET function API which is in app/api/cart/route.ts and I will than…

no iam
- 1
- 2
0
votes
0 answers
how can I get request body in GET request in next v13
here request.json() gives me error but it works correctly for POST request for eg.
how can I resolve this issue?
0
votes
1 answer
"How can I resolve an issue when accessing 'request.body' in an async function, which returns a 'ReadableStream' object instead of the expected data?"
When i create my CRUD in Nextjs13, typescript, and prisma
the GET method handler works correctly, but the PUT give me some errors and i want to know what i doing wrong
when y get the request its says to me:
Here is the request body:
ReadableStream {…

Dario Coronel
- 119
- 2
- 10
0
votes
0 answers
Unable to log in using my React app due to cross error
Unable to log in using my React app. I have created API endpoint using next js and trying to access that endpoint in react application.
My Api service is run at port number 3000 and my react app run on 8080 port that's why I got the Cross error.
I…

msrajwat298
- 156
- 1
- 2
- 9
0
votes
0 answers
NextJS API axio setup
Setup:
I have a NextJS application that fetches data from several external APIs and I want its own Next API to act as a gateway to determine which request goes where (that way I can neatly encapsulate the different API configurations and not worry…

Almaron
- 4,127
- 6
- 26
- 48
0
votes
0 answers
NEXTJS 13.2 APP Directory API route unable to import
I'm having trouble importing something to the new APP directory API route. When I use the following code, everything works fine and I get a 200 status response:
export async function POST(request) {
return new Response("hello world", {
status:…

kerim p.
- 35
- 6
0
votes
1 answer
How can I use the nextjs API route in my deployment environment?
my nextjs version - 13.2.1
First of all, the code below works normally in a local environment.
// src/pages/api/md/index.ts
// get markdowns data
import type { NextApiRequest, NextApiResponse } from "next";
import { join } from "path";
import fs…

DEVjohnFE
- 1
- 1