i have made a login and register pages with AUTH and it was working and after that ,I want to receive data from my database . so ,I change the if else statement after that the data match is working is not taking me to home page I tried some ways to fix it but it doesn't work error:Data Matched
so here we see the api is working my php code
CodePudding user response:
The error message in the screenshot does not match the message from the condition.
Try to change the condition as shown below:
const {message} = responseJson;
if (typeof message === 'string' && message.toLowerCase().trim() === 'data matched') {
// do navigation here
}
const oldVerify = (responseJson) => (responseJson === 'Data Matched');
const newVerify = (responseJson) => (typeof responseJson === 'string' && responseJson.toLowerCase().trim() === 'data matched');
const cases = ['Data Matched', 'Data matched', 'data MATCHED', ' data matched ', 'data matched'];
cases.forEach((_case) => {
console.log('======');
console.log(`Case: "${_case}"`);
console.log('Old verify:', oldVerify(_case));
console.log('New verify:', newVerify(_case));
});
I advise you to publish your code in plain text in the future :)