[Fixed]-Why am I unable to get response from my API in django rest framework via jquery?

1👍

You are passing your username and password incorrectly when making the request. This is discussed in this SO question.

Try this method instead.

$.ajax
({
  type: "GET",
  url: "http://127.0.0.1:8000/api/grocery/subcategories/?format=json",
  dataType: 'json',
  headers: {
    "Authorization": "Basic " + btoa("ratan:qazwsxedc123")
  },
  success: function (){
    console.log('ratan'); 
  }
});
👤Kieran

Leave a comment