2

Hello everyone i'm working with apisause(axios wrapper) and calling an api to get statistics, the results is numbers always but i have a special case when the result is 0 axios somehow convert it into null

here is the response from Preview Tap

enter image description here

and when i log the response from axios this is what i get

enter image description here

Any clue Why this is happening ?

Thanks in Advance.

1 Answers1

0

Based on the Content-length: "1" I would say, that's the answer from resource. Could you try hitting API with Postman/Fiddler or Swagger UI?

Sebastian Busek
  • 952
  • 1
  • 14
  • 28
  • I did on Swagger but it gives 0 `content-length: 1 content-type: application/json; charset=utf-8 date: Mon, 08 Feb 2021 12:02:24 GMT server: Microsoft-IIS/10.0 x-powered-by: ASP.NET` – Mohammed Saber Mohammed Feb 08 '21 at 12:08
  • 1
    If the Swagger responses with same response, then that's actual response from the server. The thing is that content-type is set to application/json, but the response contains "0" and it isn't valid JSON response, so the axios makes a transformation to null (0 = invalid json = null response). If server would response "{}" then the data would be an empty object. – Sebastian Busek Feb 08 '21 at 15:52