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);

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);