1👍
According to the docs there is no data member of WSGIRequest
. You will need to refer to the body
attribute instead.
0👍
data is part of the rest_framework. You need to decorate the view with an api_view.
Just add "@api_view([‘POST’])" before the def save_stripe_info(request).
It should be:
@api_view(['POST'])
def save_stripe_info(request):
print('this => ',request.data)
data = request.data
email = data['email']
payment_method_id = data['payment_method_id']
# 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}
}
)
or just load the body in json.
data = json.loads(request.body)
- [Answered ]-Django: where to find models field type translation to postgres
- [Answered ]-Query Values Muliple Field Foreign Key Column
- [Answered ]-Django pass var from view to two template in the same time
Source:stackexchange.com