export const getUsers = async() => {
try {
await axios.get(`${URL}/all`)
} catch (error) {
console.log("Error while calling getUsers API", error);
}
}
const getAllUsers = async () => {
let response = await getUsers();
console.log(response);
}
When i console.log the data i get undefinded values but i can see the data in the network.
Help me solve this problem.
CodePudding user response:
You are not returning the result, Use this.
export const getUsers = async() => {
try {
const response = await axios.get(`${URL}/all`)
return response.data
} catch (error) {
console.log("Error while calling getUsers API", error);
}
}
const getAllUsers = async () => {
let response = await getUsers();
console.log(response);
}