1
I’m willing to expect the value of one Precedent that is inside another
const URL = 'url da api que eu quero consumir'
const AuthStr = 'meu token'
function GET (){
axios.get(URL, { headers: { Authorization: AuthStr } })
.then(response => {
console.log(response.data);
return response.data
})
.catch((error) => {
console.log('error ' + error);
});
};
app.get("/", (request, response) => {
let data = GET();;
return response.json(data);
})
the problem is that I can’t make the app.get wait for Xios to return JSON
hello thank you so much was this push I needed, had previously testing using async await but was not understanding how to do I put the async directly in the express parameter and it worked like this app.get("/", async (request, Response) => { Return data = await GET(); }
– Otávio Burato