Skip to content
Advertisement

Axios is returning empty string value

JavaScript

The problem I’m facing here was, whenever I fetch the data with a button click (the button that leads to this route), the data will be fetch successfully, but whenever I input the link address directly myself in the browser, It keeps returning empty string when i console.log the data (Like this <empty string>), and keep throwing error saying “allCars.map is not a function.

Advertisement

Answer

you try initialing “allProfiles” with empty array like this:

JavaScript

empty string seem tobe different from an Array come from api response

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement