SyntaxError: Unexpected end of JSON input
Answered
Atlantic mackerel posted this in #help-forum
Atlantic mackerelOP
hey guys, im trying to fetch data to my own api server
I tried this:
but the error said:
even though on client's logging work just sooo fine (like the photo) but
Why this error has been occurred?
I tried this:
'use client'
import {getAccountProfile} from "@/app/api/auth/account/user";
export default async function Home({params}: { params: { uuid: string } }) {
let res = await getAccountProfile(params.uuid);
res.json().then((result) => {
console.log(result)
})
return (
<div className="">
<div>Hi there!</div>
</div>
)
}
but the error said:
[NEXT] ⨯ unhandledRejection: SyntaxError: Unexpected end of JSON input
[NEXT] at JSON.parse (<anonymous>)
[NEXT] at parseJSONFromBytes (node:internal/deps/undici/undici:5419:19)
[NEXT] at successSteps (node:internal/deps/undici/undici:5390:27)
[NEXT] at fullyReadBody (node:internal/deps/undici/undici:1501:9)
[NEXT] at async specConsumeBody (node:internal/deps/undici/undici:5399:7)
[NEXT] ✓ Compiled /api/auth/[...nextauth] in 132ms (314 modules)
even though on client's logging work just sooo fine (like the photo) but
Why this error has been occurred?
Answered by Jesse
all you need to do is res.then not res.json().then, can you show the code for getAccountProfile
3 Replies
all you need to do is res.then not res.json().then, can you show the code for getAccountProfile
Answer
did it work @Atlantic mackerel
@Jesse did it work <@273686048121290763>
Atlantic mackerelOP
OH yeah sorry I didn't saw that I fix it on my own thank you!! 🙂