Hello and welcome to the freeCodeCamp community~!
That screenshot is too small to read. Can you share your code (on CodePen, or GitHub), a live version of your app, and the text of the error message?
Hi thank you for the reply. This my code written in codepen. https://codepen.io/Deku/pen/dyMRdGW.
This is the error :
Uncaught (in promise) TypeError: Cannot read property ‘replace’ of undefined
at setIcons (app.js:36)
at app.js:29
setIcons @ app.js:36
(anonymous) @ app.js:29
Promise.then (async)
(anonymous) @ app.js:21
Okay,
The error comes from your icon
variable being undefined
. It looks like you are trying to use object destructuring here:
const {temp, weather, icon} = data.current;
However, the icon
property is not in data.current
, but in data.current.weather
.
I am able to access the icon value so:
const {temp, weather} = data.current;
const icon = data.current.weather[0].icon;
This removes the icon.replace
error, which should get you moving forward again.
Yes it worked thank you very much for your clear answer.