File tree Expand file tree Collapse file tree 1 file changed +17
-16
lines changed Expand file tree Collapse file tree 1 file changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -69,12 +69,15 @@ const styles = StyleSheet.create({
69
69
} ,
70
70
} ) ;
71
71
72
+ const DEFAULT_GOOGLE_API_URL =
73
+ 'https://places.googleapis.com/v1/places:autocomplete' ;
72
74
const GooglePlacesTextInput = forwardRef (
73
75
(
74
76
{
75
77
apiKey,
76
78
value,
77
79
placeHolderText,
80
+ proxyUrl,
78
81
languageCode,
79
82
includedRegionCodes,
80
83
types = [ ] ,
@@ -136,22 +139,20 @@ const GooglePlacesTextInput = forwardRef(
136
139
137
140
try {
138
141
setLoading ( true ) ;
139
- const response = await fetch (
140
- 'https://places.googleapis.com/v1/places:autocomplete' ,
141
- {
142
- method : 'POST' ,
143
- headers : {
144
- 'Content-Type' : 'application/json' ,
145
- 'X-Goog-Api-Key' : apiKey ,
146
- } ,
147
- body : JSON . stringify ( {
148
- input : processedText ,
149
- languageCode,
150
- ...( includedRegionCodes ?. length > 0 && { includedRegionCodes } ) ,
151
- ...( types . length > 0 && { includedPrimaryTypes : types } ) ,
152
- } ) ,
153
- }
154
- ) ;
142
+ const API_URL = proxyUrl ? proxyUrl : DEFAULT_GOOGLE_API_URL ;
143
+ const response = await fetch ( API_URL , {
144
+ method : 'POST' ,
145
+ headers : {
146
+ 'Content-Type' : 'application/json' ,
147
+ 'X-Goog-Api-Key' : apiKey ,
148
+ } ,
149
+ body : JSON . stringify ( {
150
+ input : processedText ,
151
+ languageCode,
152
+ ...( includedRegionCodes ?. length > 0 && { includedRegionCodes } ) ,
153
+ ...( types . length > 0 && { includedPrimaryTypes : types } ) ,
154
+ } ) ,
155
+ } ) ;
155
156
156
157
const data = await response . json ( ) ;
157
158
You can’t perform that action at this time.
0 commit comments