Skip to content
Advertisement

Value from response is undefined ReactJs

I’m trying to get values from trains such as id and number, but when I try to do that, no values shows. When I try to console.log that I get response of undefined. It works well with station.name and station.city but i does not work with station.trains.is. Here is my code:

JavaScript

And here is the response I get from API:

enter image description here

Advertisement

Answer

trains is array And you can access its members with Map or foreach

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