import { useEffect, useState } from "react";
import { View, Text, TextInput, Button, FlatList, StyleSheet, Alert } from "react-native";

const baseUrl = "http://api.weatherapi.com/v1/current.json?key=1232eaa82978466da1f81125252703&q=";

export default function Index() {
  const [city, setCity] = useState("");


  const handlePress = () => {
    console.log(city);   
  }

  useEffect(() => {
    async function fetchData() {
      try {
        const response = await fetch(`${baseUrl}Békéscsaba`);
        const data = await response.json();
        console.log(data);
      } catch (error) {
        console.error(error);
      }
    }
    fetchData();
    }, []);

  return (
    <View>
      <Text>
        Időjárás app
      </Text>
      <Button
        title="Keresés"
        onPress={handlePress} />
      <TextInput
        placeholder="Város"
        value={city}
        onChangeText={setCity} />
    </View>
  );
}