You don’t need to pass category_name
, you only need the category id. The category name should be contained in each of the item fetched from the database.
You’re getting an error because cat_id
is not defined when the function def getCategoryItems(category_name, cat_id)
is called.
I would suggest, however, if you want to really get all items to just use:
@app.route("https://stackoverflow.com/")
def getAllItems():
items = session.query(Item).all()
...
For more info, have a look at the flask-sqlalchemy docs.
solved builtins.TypeError TypeError