K
K
Konstantin2021-03-10 00:18:40
React
Konstantin, 2021-03-10 00:18:40

How to get data from API and insert into React component?

I send a request to the API, the response is an object with data:

Object
       main:
              temp:200
              id:2207456


How to get the value of temp, subtract 72 from it, and insert into the code below instead of the dollar sign?

const TopComponent = ()=>{

          useEffect(() => {
          fetch("api.openweathermap.org/data/2.5/weather?q=Perm&lan...")
          .then(res => res.json())
          .then( data => console.log(data)
)
})

Return(
        <div> $ </div>
)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question