'Not able to load image using img element in ReactJS

Api: http://api.openweathermap.org/data/2.5/weather?q=Canberra,Australia&appid=8d2de98e089f1c28e1a22fc19a24ef04&units=metric

Image Source I want to load: http://openweathermap.org/img/wn/[email protected]

Code used:

<img
  src={
    'http://openweathermap.org/img/wn/' +
    {this.state.weatherdata.weather[0].icon} +
    '@2x.png'
  }
></img>


Solution 1:[1]

Did you try the following?

console.log('http://openweathermap.org/img/wn/'+{this.state.weatherdata.weather[0].icon}+'@2x.png'})

Try to console it since I dont know the details of this I cant help you, there should be a problem with your string

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Prashant G