I have an API that returns two numbers as a response. For example if I call this
$.get('/api/get_limit/').always(function(data) { console.log(data.responseText); });
I expect to see something like this in the console
Object {absolute_limit: 389, concurrent_limit: 999}
Which is what I get, except when one of these numbers is Infinity. In that case when I make the same request, the console will show
Object {readyState: 4, responseText: "{"absolute_limit":Infinity,"concurrent_limit":999.0}", status: 200, statusText: "OK"}
I checked and API is working as expected in both cases.
My question is why this happens and is there a way I can fix this without substituting Infinity with something like -1?
EDIT:
Django code for generating API with the help of Django Rest Framework
class QueriesLimit(APIView):
def get(self, request, format=None):
limit = request.user.concurrency_limit()
abs_limit = request.user.available_queries()
return Response({'concurrent_limit': limit, 'absolute_limit': abs_limit})