Issue
I want to return response to my react Js frontend here is my code
def save_stripe_info(request):
email = '[email protected]'
payment_method_id = 'pm_1K5xfXBbWBJ638dR1WMitwx1'
# creating customer
customer = stripe.Customer.create(
email=email, payment_method=payment_method_id)
return Response(status=status.HTTP_200_OK,
data={
'message': 'Success',
'data': {'customer_id': customer.id}
}
)
but getting error
AssertionError: .accepted_renderer not set on Response
How can I resolve this. I saw this How to resolve AssertionError: .accepted_renderer not set on Response in django and ajax but this is for only django and returning an HTML page as a template
How can I solve this error
Solution
in your views.py file from rest_framework.decorators import api_view
and then before the defination of function write @api_view(['POST'])
@api_view(['POST'])
def save_stripe_info(request):
email = '[email protected]'
payment_method_id = 'pm_1K5xfXBbWBJ638dR1WMitwx1'
# creating customer
customer = stripe.Customer.create(
email=email, payment_method=payment_method_id)
return Response(status=status.HTTP_200_OK,
data={
'message': 'Success',
'data': {'customer_id': customer.id}
}
)
hope this will solve your problem!
Answered By - mujahid
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.