I'm building a Expo/React Native app where I use fetch and credentials (cookies) to log into a server.
The code works properly and looks like this:
login = async (email, password) => {
try {
var body = JSON.stringify({ email, password });
const response = await fetch('http://10.0.2.2/login', {
method: 'POST',
credentials: 'include',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: username,
password: password
})
});
if(response.hasOwnProperty('accessToken'))
{
console.log('login successfull');
console.log(response);
}
else if(response.hasOwnProperty('error'))
{
console.log('login failed');
console.log(response)
}
}
catch(e) {
console.log('error: ' + e);
}
};
My problem is, that React Native does not log out when I stop the app. I dont want to manually logout by API call.
Is there a way like in React Web, where I simply removed the cookies from Chrome and then I am logged out?
if you are using expo then you could try :
expo r -c
this would clear your project's cache and run expo