mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-06-15 17:03:26 +02:00
Matthias Kretschmann
5a310017b9
* add current and next location * add documentation * api -> src/api symlink so local dev & Vercel work * add to footer * test changes * styling changes * spacing * layout fixes
26 lines
537 B
JavaScript
26 lines
537 B
JavaScript
import axios from 'axios'
|
|
import { useEffect, useState } from 'react'
|
|
|
|
export const useLocation = () => {
|
|
const [location, setLocation] = useState()
|
|
|
|
useEffect(() => {
|
|
async function fetchData() {
|
|
try {
|
|
const response = await axios(`/api/location`)
|
|
if (!response) return
|
|
setLocation(response.data)
|
|
} catch (error) {
|
|
console.error(error.message)
|
|
}
|
|
}
|
|
fetchData()
|
|
}, [])
|
|
|
|
return {
|
|
now: location?.now,
|
|
next: location?.next,
|
|
previous: location?.previous
|
|
}
|
|
}
|