Set up pages router and moved actions.ts
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:
ChrQR 2024-05-18 01:12:41 +02:00
parent 329ee7afa5
commit ec5d7fe8f7
3 changed files with 17 additions and 18 deletions

View File

@ -1,6 +1,6 @@
"use client";
import React, { useContext, useState } from "react";
import { getLocation } from "@/app/actions";
import { getLocation } from "@/pages/api/actions";
import { LocationContext } from "@/context/LocationContext";
export default function LocationSearch() {

View File

@ -1,6 +1,6 @@
"use client";
import { getHourlyForecast } from "@/app/actions";
import { getHourlyForecast } from "@/pages/api/actions";
import Temperature from "./Temperature";
import { Forecast, WeatherContextType } from "@/types/types";
import { createContext, useContext, useEffect, useState } from "react";
@ -15,7 +15,6 @@ export const WeatherContext = createContext<WeatherContextType>({
setWeather: () => {}, // Default function, does nothing
});
export default function WeatherNow() {
const { geoLocation } = useContext(LocationContext);
const [weather, setWeather] = useState<Forecast>(defaultHourlyForecast);
@ -44,7 +43,7 @@ export default function WeatherNow() {
<WeatherHero />
<Temperature />
<h2 className="mt-2 text-xl">And the forecast for the coming week</h2>
<CardContainer weather={weather}/>
<CardContainer weather={weather} />
</WeatherContext.Provider>
</div>
);

View File

@ -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}`;
console.log(`Fetching URL: ${url}`);
console.log(`Fetching location`);
try {
const res = await fetch(url);