Currently, responses from the database for empty sets include HTTP codes that might suggest to user's there is an error retrieving data that might be there.
Here are two examples:
@app.route("/api/products", methods=["GET"])
def get_products():
offset = request.args['offset']
limit = request.args['limit']
products = Product.query.order_by(
Product.post_date.desc()).offset(offset).limit(limit)
products_serialized = []
for product in products:
products_serialized.append(product.serialize())
if products:
return jsonify(products=products_serialized)
return jsonify(error=True), 403
@app.route("/api/user", methods=["GET"])
@requires_auth
def get_user():
return jsonify(result=g.current_user)
I'm open for any other suggestions to handle this.