-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.tsx
54 lines (48 loc) · 1.43 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React, { useEffect, useState } from 'react';
import { StyleSheet, Text, View, TouchableOpacity } from 'react-native';
import { StatusBar } from 'expo-status-bar';
import * as Linking from 'expo-linking';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { discogsFetch } from './lib/DiscogsOAuth';
export default function App() {
const [data, setData] = useState('');
const getDiscogsIdentity = async () => {
const response = await discogsFetch('oauth/identity');
const json = await response.json();
setData(json);
};
const clearLocalStorage = () => {
setData('');
AsyncStorage.clear();
};
return (
<View style={styles.container}>
<TouchableOpacity onPress={getDiscogsIdentity} style={styles.button}>
<Text>Retrieve Identity Data</Text>
</TouchableOpacity>
<Text />
<TouchableOpacity onPress={clearLocalStorage} style={styles.button}>
<Text>Clear local oauth token</Text>
</TouchableOpacity>
<Text />
<Text>Identity data:</Text>
<Text />
<Text style={{ marginHorizontal: 50 }}>
{data ? JSON.stringify(data) : 'Not retrieved yet.'}
</Text>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
button: {
padding: 10,
borderWidth: 1,
},
});