-4
It would look something like:
const suaFuncao = async () => {
const response = await axios.get("url_sua_api");
const { data } = response.data
return data;
}
-4
0
It would look something like:
const suaFuncao = async () => {
const response = await axios.get("url_sua_api");
const { data } = response.data
return data;
}
0
Xios works with promisse, so you need to wait for promisse to resolve at some point.
Test this code, this way you solve within the function itself:
static async findCursoPessoa(coddisciplina: string){
try {
coddisciplina = coddisciplina.replace('/', '-');
const { data } = await Axios.get(`/pessoal/pessoa/${coddisciplina}/buscarCursos`);
return data;
} catch (error) {
return error;
}
}
0
const function= async()=> {
const response = await axios.get("localhost");
const {data} = response.data
return data;
}
Browser other questions tagged react typescript axios callback
You are not signed in. Login or sign up in order to post.
Export the function and import it where you want to use it
– Rafael Costa