'error: missing FROM-clause entry for table "x" Express

Trying to fix up my first node/express GET request. Having some trouble getting it working though.

I currently am getting this error:

error: missing FROM-clause entry for table "recipe"
    at Parser.parseErrorMessage (/Users/x/Desktop/Programming/recipes/recipes/backend/node_postgres/node_modules/pg-protocol/dist/parser.js:287:98)
    at Parser.handlePacket (/Users/x/Desktop/Programming/recipes/recipes/backend/node_postgres/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/Users/x/Desktop/Programming/recipes/recipes/backend/node_postgres/node_modules/pg-protocol/dist/parser.js:39:38)
    at Socket.<anonymous> (/Users/x/Desktop/Programming/recipes/recipes/backend/node_postgres/node_modules/pg-protocol/dist/index.js:11:42)

Here is the fetch call (I am new to this so not sure if I am passing parameter correctly)

export default function GetRecipe() {
  const [name, setName] = useState('')
  const retrieveRecipe = function (e) {
    e.preventDefault()
    console.log(name)
    fetch('http://localhost:3001/getjoinedrecipes/?param1=name', {
      method: 'GET',
      headers: { 'Content-type': 'application/json' },
    })
      .then((resp) => resp.json())
      .then((json) => console.log(json))
  }
  [...]
  )
}

Here is the backend code

app.get('/getjoinedrecipes', (req, res) => {
  //get recipe id from recipe name sent in fetch request
  pool
    .query(`SELECT id FROM recipes WHERE recipe_name = ?`, [req.body.name])
    .then((result) => {
      // insert a new query here to get the rest of the recipe with the result
      pool.query(
        `SELECT * FROM ingredientrecipes INNER JOIN recipes ON ingredientrecipes.recipe_id = ${result} INNER JOIN ingredients ON ingredientrecipes.ingredient_id = ingredients.id;`
      )
    })
    //return results to front end
    .then((result) => {
      res.status(200).send(result.rows)
    })
    .catch((error) => {
      console.log(error)
      res.status(500).send(error)
    })
})


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source