Skip to content

Commit d22a947

Browse files
committed
feat: update apiKey nullable prop
when proxyUrl provided, apiKey become useless, because of when proxy to a url, proxied site use envrionment own properties
1 parent 645370d commit d22a947

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/GooglePlacesTextInput.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,15 @@ const GooglePlacesTextInput = forwardRef(
140140
try {
141141
setLoading(true);
142142
const API_URL = proxyUrl ? proxyUrl : DEFAULT_GOOGLE_API_URL;
143+
const headers = {
144+
'Content-Type': 'application/json',
145+
};
146+
if (apiKey || apiKey != '') {
147+
headers['X-Goog-Api-Key'] = apiKey;
148+
}
143149
const response = await fetch(API_URL, {
144150
method: 'POST',
145-
headers: {
146-
'Content-Type': 'application/json',
147-
'X-Goog-Api-Key': apiKey,
148-
},
151+
headers,
149152
body: JSON.stringify({
150153
input: processedText,
151154
languageCode,

0 commit comments

Comments
 (0)