I am using the django 1.11 version and django rest framework for the rest api I am passing the token value in the HTTP header in React Native using fetch
But when I am trying to retrieve the token value in django views file it is giving me error
In react Native I am passing the token value as below
fetch(url,{
method: 'get',
headers : new Headers({
'token':'token',
'Content-Type': 'application/json'
})
})
I django rest APi I am trying to fetch the token value as below
def get(self,request,**kwargs):
token = request.headers['token']
queryset=models.Schedule.objects.filter()
serializer_class= RepScheduleSerializer(queryset,many=True)
return Response(serializer_class.data)
But it is giving me error Request object has no attribute headers
I want to fetch the token value in the function