I have develop a front and back web app that consist of some chemical engineering calculations. In the designer>pipes>liquid page i send a post with two numbers to the backend, where after some calculations it returns the answer that gets rendered in the frontend.
I test on my localhost and everything went fine, nevertheless, when i uploaded all the repo to render and i use the form to do the post i get this error: SyntaxError: Unexpected end of JSON input.
I’ve been figuring out for two straight days and have no absolute clue what is causing this error. I have tried a lot of codes( CORS, json.text(), etc) and nothings seems to fix this error.
Does anyone have fixed this error? please help me.
“Unexpected end of JSON input” errors generally mean that you received a blank response back. You should inspect the content of the result to determine what you’re actually receiving (prior to parsing it), and then determine why you’re receiving unexpected content.
i will check what you said, nevertheless I’m quite surprised on my localhost worked, i mean, i receive the proper response back from the server without any problems.
I thought about the asyncronity , so y typed async/await acordingly and i’m still facing this error.
Do you know any tools to check the content of the server response?
I took your advice and used Postman and ThunderClient to send requests to my backend, I fixed some routes stuff and it works perfect, the response comes as I expect (Json or text format, tested both).
Sadly, when I test the request and response in the browser with my render static-site I’m still getting the same error “SyntaxError: Unexpected end of JSON input” in this line in my React component:
const resJson = await res.json();
I was checking this community forum and found someone who had the exact same issue like me, the thread is in the following link:
As he mentions, he changed some stuff on his proxy on the frontend package json, unfortunately he doesn’t specify what actually did he change. I asked gemini and google what is that proxy but i don’t understand quite well what is the purpose of that proxy in order to know if that’s where my error comes from.
I also tried to contact him on this forum but i guess it is not possible, there is no way to land messages between members, could be a future feature, perhaps. .
Jason, do you have any clue or any blog where I can read about this proxy thing and figure this out?