I have this code
type UserService = {
getUserRole: () => string
}
const auth = useAuth();
const useUserService: UserService = {
getUserRole: () => {
return Axios({
method: "get",
url: "https://<url>",
headers: {
"Authorization": `Bearer ${auth.user.access_token}`
}
}).then((response) => {
return response.data;
}).catch((error) => {
console.log(error);
});
}
}
export default useUserService
I'm getting error message
Type '() => Promise<any>' is not assignable to type '() => string'.
Type 'Promise<any>' is not assignable to type 'string'.
How do I return the response (which is a string) from Axios?