I am using the web SDK to interact with the Appwrite GraphQL API for user login. However, I am encountering an issue where the API returns a 200 response and the following response., even when I enter an incorrect email or password.
{
"errors": [
{
"message": "Invalid credentials. Please check the email and password.",
"extensions": {
"category": "appwrite"
},
"locations": [
{
"line": 5,
"column": 9
}
],
"path": [
"accountCreateEmailSession"
]
}
],
"data": {
"accountCreateEmailSession": null
}
}
My code:
const login = async (email, password) => {
try {
const res = await graphql.mutation({
query: `mutation (
$email: String!,
$password: String!,
) {
accountCreateEmailSession(
email: $email,
password: $password,
) {
_id
}
}`,
variables: {
email: email,
password: password,
},
});
console.log(res);
} catch (error) {
console.log(error);
throw error;
}
};
It should log the error message from the catch block not from the try block when a user enters a wrong email or password.
Anyone please help me with this.