O
O
Ostap2020-04-27 23:38:05
API
Ostap, 2020-04-27 23:38:05

Is it correct to get data from the API?

Hello. I fight half a day. Hope you! I'm building an application that receives data from the API
Essence The component that receives the data does not see it, but it exists.

The component wrapped in Consumer passes data to the child component, but the child component does not receive anything.

<ErrorBoundary>
     <OpenServiceConsumer>
         {(openService) => {
            // console.log(`res ${openService.getArrival(selected.selected, 60)}`);
           return (<FlightsTable data={openService.getArrival(selectedAirport.selectedAirport, 360)}  />)}}
    </OpenServiceConsumer>
</ErrorBoundary>


In the child component, I output props to the console and get props.data [object Promise] And the request status is 200. If I enter the URL directly, then in the tab I get a response in the form of an array.
console.log(`props.data ${props.data}`);

[{"icao24":"484d10","firstSeen":1587929916,"estDepartureAirport":"GMMN","lastSeen":1587940304,"estArrivalAirport":"EHAM","callsign":"TFL8378 ","estDepartureAirportHorizDistance":1307,"estDepartureAirportVertDistance":24,"estArrivalAirportHorizDistance":1374,"estArrivalAirportVertDistance":26,"departureAirportCandidatesCount":0,"arrivalAirportCandidatesCount":1},....]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Shamanov, 2020-04-28
@SilenceOfWinter

aplikukha, prilozha, react, well, I didn’t get to the basics of js
ps for harmful young grandfathers: "one of the foundations of modern js"

S
Sergey Ilyin, 2020-04-28
@sunsexsurf

Tell me, what did you not like about the received JSON?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question