Set up pages router and moved actions.ts
All checks were successful
Docker Build & Publish / Build Docker (push) Successful in 1m7s
All checks were successful
Docker Build & Publish / Build Docker (push) Successful in 1m7s
This might have been the problem all along. I thought server components would fix it, but in order to not expose my api key i have to create an API.
This commit is contained in:
parent
329ee7afa5
commit
ec5d7fe8f7
@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import React, { useContext, useState } from "react";
|
import React, { useContext, useState } from "react";
|
||||||
import { getLocation } from "@/app/actions";
|
import { getLocation } from "@/pages/api/actions";
|
||||||
import { LocationContext } from "@/context/LocationContext";
|
import { LocationContext } from "@/context/LocationContext";
|
||||||
|
|
||||||
export default function LocationSearch() {
|
export default function LocationSearch() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { getHourlyForecast } from "@/app/actions";
|
import { getHourlyForecast } from "@/pages/api/actions";
|
||||||
import Temperature from "./Temperature";
|
import Temperature from "./Temperature";
|
||||||
import { Forecast, WeatherContextType } from "@/types/types";
|
import { Forecast, WeatherContextType } from "@/types/types";
|
||||||
import { createContext, useContext, useEffect, useState } from "react";
|
import { createContext, useContext, useEffect, useState } from "react";
|
||||||
@ -15,7 +15,6 @@ export const WeatherContext = createContext<WeatherContextType>({
|
|||||||
setWeather: () => {}, // Default function, does nothing
|
setWeather: () => {}, // Default function, does nothing
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export default function WeatherNow() {
|
export default function WeatherNow() {
|
||||||
const { geoLocation } = useContext(LocationContext);
|
const { geoLocation } = useContext(LocationContext);
|
||||||
const [weather, setWeather] = useState<Forecast>(defaultHourlyForecast);
|
const [weather, setWeather] = useState<Forecast>(defaultHourlyForecast);
|
||||||
@ -44,7 +43,7 @@ export default function WeatherNow() {
|
|||||||
<WeatherHero />
|
<WeatherHero />
|
||||||
<Temperature />
|
<Temperature />
|
||||||
<h2 className="mt-2 text-xl">And the forecast for the coming week</h2>
|
<h2 className="mt-2 text-xl">And the forecast for the coming week</h2>
|
||||||
<CardContainer weather={weather}/>
|
<CardContainer weather={weather} />
|
||||||
</WeatherContext.Provider>
|
</WeatherContext.Provider>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -10,7 +10,7 @@ export async function getLocation(searchLocation: string): Promise<coordType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const url = `https://maps.googleapis.com/maps/api/geocode/json?address=${searchLocation}&key=${placesKey}`;
|
const url = `https://maps.googleapis.com/maps/api/geocode/json?address=${searchLocation}&key=${placesKey}`;
|
||||||
console.log(`Fetching URL: ${url}`);
|
console.log(`Fetching location`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(url);
|
const res = await fetch(url);
|
Loading…
Reference in New Issue
Block a user