Nenhuma descrição

HomeScreen.js 954B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 HomeScreen({ navigation }) {
  6. const credentials = async ()=>{
  7. const token = await SecureStore.getItemAsync('token')
  8. const id = await SecureStore.getItemAsync('id')
  9. console.log(token, id)
  10. let response = await Axios({
  11. url: 'http://8c4029a33a9a.ngrok.io/api/hello',
  12. method: 'GET',
  13. headers: {
  14. Authorization: `Token ${token}`
  15. }
  16. })
  17. console.log(response.data.msg)
  18. }
  19. return (
  20. <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
  21. <Button
  22. onPress={() => navigation.navigate('Notifications')}
  23. title="Go to notifications"
  24. />
  25. <Button
  26. onPress={credentials}
  27. title="Prueba"
  28. />
  29. </View>
  30. );
  31. }
  32. export default HomeScreen