Skip to content

Upload to Database does not work correctly🤯 #773

Answered by doemser
gwittm asked this question in Web
Discussion options

You must be logged in to vote

Here is how I found the problem:

  1. I went to pages/api/recipes/index.js and added a console.log to your POST method like this:
if (request.method === "POST") {
    const recipes = request.body;
    console.log("RECIPES", recipes);
...
  1. After submitting a recipe and inspecting the log I recognized that the data I received had no ingredients included and was not how I expected it.

  2. I went to components/RecipeForm.js and found that the ingredients are not passed to the onSubmit function

export default function RecipeForm({ onSubmit, formName, defaultData }) {
  function handleSubmit(event) {
    event.preventDefault();
    const formData = new FormData(event.target);
    const data = Object

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by doemser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
2 participants