I'm creating a javascript code to check 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 would like to know how to return the "data" object out of the scope of the time function.