moved keys to API keys to .env.local
This commit is contained in:
		
							parent
							
								
									e98edf431d
								
							
						
					
					
						commit
						1772c0b543
					
				@ -3,7 +3,7 @@ import { Forecast, LocationType, coordType } from "@/types/types";
 | 
			
		||||
 | 
			
		||||
//takes address and returns coords in obj as {lat: number, lng: number}
 | 
			
		||||
export async function getLocation(searchLocation: string): Promise<coordType>{
 | 
			
		||||
    const placesKey = "AIzaSyBf1ip4XogdC6XmbfDhxS_RJDOSieycJpQ";
 | 
			
		||||
    const placesKey = process.env.PLACES_API;
 | 
			
		||||
    const url = `https://maps.googleapis.com/maps/api/geocode/json?address=${searchLocation}&key=${placesKey}`;
 | 
			
		||||
    const res = await fetch(url);
 | 
			
		||||
    if (!res.ok) {
 | 
			
		||||
@ -16,7 +16,7 @@ export async function getLocation(searchLocation: string): Promise<coordType>{
 | 
			
		||||
// takes coordinates in coordType format and returns json with weather forecast.
 | 
			
		||||
export async function getForecast(geoLocation: coordType): Promise<Forecast> {
 | 
			
		||||
    const { lat, lng } = geoLocation;
 | 
			
		||||
    const appId = '546911d860cb81f16585f7973b394b70';
 | 
			
		||||
    const appId = process.env.WEATHER_API;
 | 
			
		||||
    const res = await fetch(
 | 
			
		||||
      `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lng}&appid=${appId}`
 | 
			
		||||
    );
 | 
			
		||||
@ -25,4 +25,4 @@ export async function getForecast(geoLocation: coordType): Promise<Forecast> {
 | 
			
		||||
    }
 | 
			
		||||
    const data: Forecast = await res.json();
 | 
			
		||||
    return data;
 | 
			
		||||
  }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user