1
I am creating a javascript code to query the temperature:
const tempo = () => {
const axios = require("axios");
const TOKEN = "#myToken";
axios.get(`http://apiadvisor.climatempo.com.br/api/v1/locale/city?name=Joinville&state=SC&token=${TOKEN}`).then((response) => {
const id = response.data[0]["id"];
axios.get(`http://apiadvisor.climatempo.com.br/api/v1/forecast/locale/${id}/days/15?token=${TOKEN}`).then((response => {
const local = response.data;
const dados = {
cidade: local.name,
estado: local.state,
data: local.data[0].date_br,
probChuva: local.data[0].rain.probability,
temperatura: {
descricao: local.data[0].text_icon.text.phrase.reduced,
max: local.data[0].temperature.max,
min: local.data[0].temperature.min
}
}
}));
});
}
I wonder how do I return the object "data" out of the scope of the function time.
Thank you for giving me this help! It helped me to see that there is so much I can learn.
– Dougwn