Sage
Sage5mo ago

Sage - Am I calling the API Key correctly ?

Am I calling the API Key correctly ?
No description
Solution:
Don't directly inject all the params directly. You can refer to this sample node which which is for findplacefromtext/json , you can use the AI to edit this one to support for URL.
Jump to solution
4 Replies
Gaurav Chadha
Gaurav Chadha5mo ago
Hi @Sage, if the apiKey requires to be in the query parameter according to your request, then yes it should work. Or you can share the API structure example as well.
Sage
Sage5mo ago
import axios from 'axios'; export default async function getPlaceDetails({ businessUrl, apiKey }) { const findPlaceUrl = https://maps.googleapis.com/maps/api/place/findplacefromurl/json?input=${encodeURIComponent(businessUrl)}&inputtype=textquery&fields=place_id&key=${apiKey}; let response = await axios.get(findPlaceUrl); if (response.data.candidates && response.data.candidates.length > 0) { const placeId = response.data.candidates[0].place_id; const detailsUrl = https://maps.googleapis.com/maps/api/place/details/json?place_id=${placeId}&fields=name,formatted_address,geometry&key=${apiKey}; response = await axios.get(detailsUrl); if (response.data.result) { return { businessName: response.data.result.name, businessAddress: response.data.result.formatted_address, businessCoordinates: response.data.result.geometry.location, } } else { throw new Error('No place details found'); } } else { throw new Error('No place id found'); } }
Solution
Gaurav Chadha
Gaurav Chadha5mo ago
Don't directly inject all the params directly. You can refer to this sample node which which is for findplacefromtext/json , you can use the AI to edit this one to support for URL.
Sage
Sage5mo ago
Thank you !