0
votes

I have connected my app to google places API and I was working until a certain point (I'm not sure what changed) but the API is no longer receiving my request when I go check on the google developers console I neither shows 4XX or 2XX(previously showing)

this is my code

import React,{useState,useEffect} from "react";
import { View ,Text, TextInput ,SafeAreaView, ListView } from "react-native";

import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
import { useNavigation } from "@react-navigation/core";


import Styles from "./style";
import Place from "./PlaceRow";

const HomePlace={
    description:"Home",
    geometry:{location:{lat:48.8152937,lng:2.4597668}}
};

const WorkPlace={
    description:"Work",
    geometry:{location:{lat:48.8152837,lng:2.4597659}}
};

const DestinationSearch=(props)=>{

    const navigation= useNavigation();


    const [fromText , setFromText] =  useState("");
    const [destinationText , setDestinationText] = useState("");

    useEffect(() => {

        if(fromText && destinationText) {
        navigation.navigate("SearchResults",{
            fromText,
            destinationText
        })
            
        }
    }, [fromText,destinationText]);
    
    return (
        <SafeAreaView>
            <View  style={Styles.container}>

                <GooglePlacesAutocomplete
                placeholder="From"
                onPress={(data, details = null) => {
                    // 'details' is provided when fetchDetails = true
                    setFromText(data, details);
                }}
                currentLocation={true}
                currentLocationLabel='Current location'
                styles={{
                    textInput:Styles.TextInput,
                    container:{
                        position:"absolute",
                        top:0,
                        left:10,
                        right:10,
                    },
                    listView:{
                        position:"absolute",
                        top:100,
                    }
                }}
                query={{
                    key: 'API CREDENTIALS',
                    language: 'en',
                }}
                predefinedPlaces={[HomePlace,WorkPlace]}
                renderRow={(data)=><Place data={data}/>}
                />


                <GooglePlacesAutocomplete
                 placeholder="Where to?" 
                onPress={(data, details = null) => {
                    // 'details' is provided when fetchDetails = true
                    setDestinationText(data, details);
                }}
                styles={{
                    textInput:Styles.TextInput,
                    container:{
                        position:"absolute",
                        top:55,
                        left:10,
                        right:10,
                    }
                }}
                query={{
                    key: 'API CREDENTIALS',
                    language: 'en',
                }}
                predefinedPlaces={[HomePlace,WorkPlace]}
                renderRow={(data)=><Place data={data}/>}
                />
                

                <View style={Styles.circle}/>
                <View style={Styles.line}/>
                <View style={Styles.square}/>
            </View>
        </SafeAreaView>
    );
};
export default DestinationSearch;

I have tried

  • using the testing code provided by react-native-google-places-autocomplete
  • creating a new API credential
  • waited for several days in case the server is down
  • reinstalling the NPM package
  • reenabled Google Places API
1
Maybe you went over your account limit? Check your account billing. - yudhiesh
I checked that too , i was using other google services too and they are working - Misa

1 Answers

0
votes

I solved the problem, turns out my android studio emulator disconnected to it's wifi (dumb reason to get stuck on)