adrianhajdin / project_next_14_ai_prompt_sharing

Next.js recently became the official React framework as outlined in React docs. In this course, you'll learn the most important Next.js concepts and how they fit into the React ecosystem. Finally, you'll put your skills to the test by building a modern full-stack Next 14 application.
https://www.jsmastery.pro/ultimate-next-course
2.87k stars 421 forks source link

/api/prompt/new 500 Internal Server Error) #6

Open davidcastagnetoa opened 1 year ago

davidcastagnetoa commented 1 year ago

POST http://localhost:3000/api/prompt/new 500 (Internal Server Error) page.jsx:22

`try { const response = await fetch("/api/prompt/new", { method: "POST", body: JSON.stringify({ prompt: post.prompt, userId: session?.user.id, tag: post.tag, }), });

  if (response.ok) {
    router.push("/");
  }
} catch (error) {
  console.log(error);
} finally {
  setIsSubmitting(false);
}

};`

I dont have idea Why

ALIRAZA17 commented 1 year ago

@davidcastagnetoa I got the same error and couldn't find the problem. I replaced my code with the repos code and refreshed the app. It started working. Try the same solution hope it works!

davidcastagnetoa commented 1 year ago

@ALIRAZA17 Finnally I resolved the problem, in my case I have an syntaxis error in Form.jsx, line 25 <textarea value={post.promt} onChange={(event) => setPost({ ...post, prompt: event.target.value }) } placeholder="Your AI Prompts Here!" className="form_textarea" /> Instead post.prompt, I use post.promt. I advice you to review the Form.jsx and looking for syntaxis errors, try to use ESLint in order to find more errors like this Good Luck, Happy hacking!