sensitive-blue
sensitive-blue14mo ago

Unhandled Error in logout: refine always expects a resolved promise.

logout: async ({ email, password }) => {
localStorage.removeItem("auth");
return {
success: true,
redirectTo: "/login"
}
},
logout: async ({ email, password }) => {
localStorage.removeItem("auth");
return {
success: true,
redirectTo: "/login"
}
},
migrated from v3 to v4. logout in AuthProvider error
6 Replies
kapa.ai
kapa.ai14mo ago
Hi @ganuzaz. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In refine v4, the logout method in the authProvider has been updated. You need to make sure that the promise is resolved in all cases with a return type of AuthActionResponse. When resolving the promise, you must always include a success key, and in the case of a failure, an additional error key. Here's the updated logout method for refine v4:
const authProvider = {
logout: async ({ email, password }) => {
localStorage.removeItem("auth");
return {
success: true,
redirectTo: "/login",
};
},
}
const authProvider = {
logout: async ({ email, password }) => {
localStorage.removeItem("auth");
return {
success: true,
redirectTo: "/login",
};
},
}
And the AuthActionResponse type:
type AuthActionResponse = {
success: boolean;
redirectTo?: string;
error?: Error;
[key: string]: unknown;
};
type AuthActionResponse = {
success: boolean;
redirectTo?: string;
error?: Error;
[key: string]: unknown;
};
If you still encounter an error, please make sure you have followed the migration guide correctly: Auth Provider Migration Guide (https://refine.dev/docs/migration-guide/auth-provider/) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai14mo ago
<@149140198213550080> kapa.ai is still learning and improving, please let us how it did by reacting below
sensitive-blue
sensitive-blue14mo ago
same code but still throwing the same error (refine always expect a resolved promise) @kapa.ai @kapa.ai yes, its the same xcode but its still throwing the same error : refine always expect a resolved promise
kapa.ai
kapa.ai14mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I apologize for the confusion earlier. Based on the information provided in the extracts, it seems that refine v4 always expects a resolved promise for the authProvider methods. If you're still encountering an error, please ensure that your authProvider methods are returning a resolved promise with the appropriate success key. Here's an example of a properly formatted logout method:
const authProvider = {
logout: async () => {
localStorage.removeItem("auth");
return {
success: true,
redirectTo: "/login",
};
},
};
const authProvider = {
logout: async () => {
localStorage.removeItem("auth");
return {
success: true,
redirectTo: "/login",
};
},
};
If you're still experiencing issues, it might be helpful to review the refine v4 Auth Provider Migration Guide (https://refine.dev/docs/migration-guide/auth-provider/) and the authProvider documentation (https://refine.dev/docs/api-reference/core/providers/auth-provider) to ensure that your implementation is correct. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai14mo ago
<@149140198213550080> kapa.ai is still learning and improving, please let us how it did by reacting below
sensitive-blue
sensitive-blue14mo ago
changed the parameters into params instead of {email,password}. if anybody is wondering
logout: async (params) => {
localStorage.removeItem("auth");

return {
success : true,
redirectTo : "/login"
}
},

logout: async (params) => {
localStorage.removeItem("auth");

return {
success : true,
redirectTo : "/login"
}
},