hello everybody, I have problem with my method, the return me 401,
xhr.js?ec6c:178 PUT http://127.0.0.1:8000/api/v1/profile/pin-reg/2 401 (Unauthorized) I use vueJS and axios, my view.py class RegisterPin(generics.UpdateAPIView): """ Register PIN the fist time """ serializer_class = ProfileSerializer queryset = Profile.objects.all() permission_classes = (IsAuthenticated, IsAuthorOrReadOnly) def put(self, request, pk, *args, **kwargs): try: current_user = request.user profile_users = Profile.objects.get( user_id=current_user.id) current_pin = int(request.POST.get('pin')) # register pin resp_pin = self.regpin(profile_users, current_pin) if resp_pin: resp_http = status.HTTP_200_OK msg = "your pin was registered." else: resp_http = status.HTTP_400_BAD_REQUEST msg = "you haven't a pin registered or your pin is incorrect." return JsonResponse({'data': resp_pin, 'msg': msg}, status=resp_http) except Exception: return JsonResponse({'data': 'error'}, status=status.HTTP_400_BAD_REQUEST) I try update a PIN, with method below, and my code vuejS is sendOrderBuy: function(){ var pin = this.sendData.pin; var decoded = Decode(GetLogin()); // jwt-decode plugin var configHeader = { headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + GetLogin(), } } axios.put(url_register_pin_local+decoded.user_id, configHeader) .then(response => { console.log('here PIN'); }) .catch(function (error) { console.log(decoded); console.log('error PIN'); console.log(error); //return error; }); }, please help me regards Nge Rojas -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
