Без опису

1234567891011121314151617181920212223242526272829303132333435363738
  1. import * as React from 'react';
  2. import { Button, View } from 'react-native';
  3. import * as SecureStore from 'expo-secure-store';
  4. import Axios from 'axios';
  5. function Logout({ navigation }) {
  6. const backendLogout = async()=>{
  7. const token = await SecureStore.getItemAsync('token')
  8. let response = await Axios({
  9. method: 'POST',
  10. url: 'http://7f9219a069f7.ngrok.io/api/logout',
  11. headers: {
  12. 'content-type': 'application/json',
  13. Authorization: `Token ${token}`
  14. }
  15. })
  16. console.log(response.data)
  17. }
  18. return (
  19. <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
  20. <Button onPress={
  21. ()=>{
  22. backendLogout()
  23. SecureStore.deleteItemAsync('token')
  24. SecureStore.deleteItemAsync('id')
  25. navigation.push('Login')
  26. }
  27. } title="LOGOUT" />
  28. </View>
  29. );
  30. }
  31. export default Logout
  32. // navigation.navigate('Login', {screen: 'Login'})