fix(api): Add error handling for item not found
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
219dd5deee
commit
2e646054ff
3
app.py
3
app.py
@ -203,6 +203,9 @@ def add():
|
|||||||
spider = BarcodeSpider(x_rapidapi_key=X_RapidAPI_Key)
|
spider = BarcodeSpider(x_rapidapi_key=X_RapidAPI_Key)
|
||||||
|
|
||||||
good = spider.get_good(barcode)
|
good = spider.get_good(barcode)
|
||||||
|
if not good:
|
||||||
|
response_data = {"message": "Item not found"}
|
||||||
|
return jsonify(response_data), 400
|
||||||
try:
|
try:
|
||||||
if add_product(good, location):
|
if add_product(good, location):
|
||||||
response_data = {"message": "New item added successfully"}
|
response_data = {"message": "New item added successfully"}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user