DEV Community 👩‍💻👨‍💻

Nazmul Hasan👻
Nazmul Hasan👻

Posted on

Why Axios is reducing api response?

Is there any specific reason , why axios might reduce api response? such as the response is an array and there is 2 index data , but after axios process data only one remains. And if there is 1 index , it becomes an empty array. #axios #ReactNative
My code is given below ,


let response = await axios.get(
      `$url`,
      {
        headers: {Authorization: authorize(token)},
      },
    );
    console.log(response);
Enter fullscreen mode Exit fullscreen mode

Top comments (7)

Collapse
 
dephraiim profile image
Ephraim Atta-Duncan

I don't think axios is causing this. The termimal itself is limited to displaying data, especially the VSCode integreated terminal. The whole response object in axios is very large, including the status codes and the others. Try getting only the data using response.data. If it doesn't work, I guess you should paste the whole response object here for us to see.

Collapse
 
itsjzt profile image
Saurabh Sharma
  1. Are you sure axios is causing this? Did you tried fetch?
  2. Maybe Json.parse is causing it
Collapse
 
hasan101002 profile image
Nazmul Hasan👻

i am quite sure that axios is causing this, cause i didn't use any seperate parser . And i can see the original data in network request. But when axios process the response in response.data , it gets reduced . And i didn't try fetch .

Collapse
 
myogeshchavan97 profile image
Yogesh Chavan

It will be better If you could share the code which takes the data from API using Axios so it's easy to understand what is happening.

Thread Thread
 
hasan101002 profile image
Nazmul Hasan👻

updated the post

Thread Thread
 
myogeshchavan97 profile image
Yogesh Chavan

The code looks good to me. I don't see anything wrong here. something is wrong in the backend only from where you're taking the response.

Collapse
 
damiensavoldelli profile image
damienSavoldelli

Could you share an example of data in your network request & what you have in console ?

Build Anything...


Use any Linode offering to create something for the DEV x Linode Hackathon 2022. A variety of prizes are up for grabs, inculding $1,000 USD. 👀

Join the Hackathon <-