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');
}
});
Source:stackexchange.com