From d16eae2d9d103911f96061de8c31903725634a07 Mon Sep 17 00:00:00 2001 From: Fitti Date: Tue, 22 Jun 2021 17:12:55 +0200 Subject: [PATCH] Return json instead of plain text from API --- lnbits/extensions/twitchalerts/views_api.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lnbits/extensions/twitchalerts/views_api.py b/lnbits/extensions/twitchalerts/views_api.py index ffef7d563..fb2c8e233 100644 --- a/lnbits/extensions/twitchalerts/views_api.py +++ b/lnbits/extensions/twitchalerts/views_api.py @@ -1,4 +1,4 @@ -from quart import g, redirect, request +from quart import g, redirect, request, jsonify from http import HTTPStatus from lnbits.decorators import api_validate_post_request, api_check_wallet_key @@ -93,8 +93,17 @@ async def api_post_donation(): if charge and charge.paid: print("This endpoint works!") if await post_donation(donation_id): - return "Posted!", HTTPStatus.OK + return ( + jsonify({"message": "Posted!"}), + HTTPStatus.OK + ) else: - return "Already posted!", HTTPStatus.BAD_REQUEST + return ( + jsonify({"message": "Already posted!"}), + HTTPStatus.BAD_REQUEST + ) else: - return "Not a paid charge!", HTTPStatus.BAD_REQUEST + return ( + jsonify({"message": "Not a paid charge!"}), + HTTPStatus.BAD_REQUEST + )