How to access get request data in django rest framework

If you are using class based views :

POST provides data in request.data and GET in request.query_params

If you are using function based views:

request.data will do the work for both methods.

axios does not support sending params as body with get method , it will append params in url. so if you are using axios you will have to use query_params

Axios example code:

axios.get(API_URL, {
            params: {
                testData: 'test data',
                pageNum: 1
            }
        })
        .then(res => {
            console.log(res);
        })
        .catch(err => {
            console.log(err.response.data);
        });

DRF example code:

Class TestView(APIView):
    def get(self, request):
        test_data_var = request.query_params['testData']
        page_num_var = request.query_params['pageNum']

Note: If you're testing it in postman then put the get request query params in Params tab.