Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, {useState, useEffect} from "react";
- import {StyleSheet, Text, View, TouchableOpacity} from 'react-native';
- const App = () => {
- const [hasError, setErrors] = useState(false);
- const [state, setState] = useState({});
- useEffect(() => {
- async function fetchData() {
- const res = await fetch("https://oauth.vk.com/authorize?client_id=7563861&display=mobile&redirect_uri=https://auth.expo.io/@laneboyandrew/beautifulPlaces&response_type=token&v=5.92");
- res
- .json()
- .then(res => setState(res))
- .catch(err => setErrors(err));
- if (state.result.type === 'success') {
- const res = await fetch('https://api.vk.com/method/users.get?v=5.92&access_token=' + state.result.params.access_token);
- res
- .json()
- .then(res => setState(res))
- .catch(err => setErrors(err));
- }
- }
- fetchData();
- });
- return (
- <View>
- <Text>{JSON.stringify(state)}</Text>
- <Text> Has error: {JSON.stringify(hasError)}</Text>
- </View>
- );
- };
- export default App;
Add Comment
Please, Sign In to add comment