[Answered ]-How can i send updated request from 1 api to another api

1👍

You can do something like this to get the updated user.

@action(detail=False, methods=['get'], authentication_classes=(JWTAuthentication, SessionAuthentication))
def profile(self, request):
    user = self.get_user()
    if not user:
        raise AuthenticationFailed()
    else:
        user = AppUser.objects.get(pk=self.get_user().pk)
    return Response(
        {"status": 200, "message": "Success", "data": UserSerializer(user).data},
        status=status.HTTP_200_OK)


@action(detail=False, methods=['post'], authentication_classes=(JWTAuthentication, SessionAuthentication))
def update_profile(self, request):

    profile_serialize = ProfileSerializer(data=request.data)
    profile_serialize.is_valid(raise_exception=True)

    AppUser.objects.filter(pk=self.get_user().pk).update(**profile_serialize.data)

    return Response(self.profile(request).data)

Leave a comment