mirror of
https://github.com/skidoodle/albert.lol.git
synced 2025-02-15 06:09:15 +01:00
swr
This commit is contained in:
parent
2b6124cbf9
commit
4deca5056f
4 changed files with 33 additions and 13 deletions
|
@ -1,17 +1,23 @@
|
|||
import Image from 'next/image'
|
||||
import Link from 'next/link'
|
||||
import React from 'react'
|
||||
import useSWR from 'swr'
|
||||
|
||||
import { socials } from 'components/data/socials'
|
||||
import { Icon } from 'components/Icon'
|
||||
import { Footer } from 'components/Footer'
|
||||
import { Loading } from 'components/Loading'
|
||||
|
||||
import { Toaster } from 'react-hot-toast'
|
||||
import { FaSpotify } from 'react-icons/fa'
|
||||
|
||||
import { GetServerSideProps } from 'next'
|
||||
const fetcher = (url: RequestInfo) => fetch(url).then(r => r.json())
|
||||
|
||||
export default function() {
|
||||
const { data: spotify } = useSWR('/api/spotify', fetcher)
|
||||
|
||||
if(!spotify) return <Loading />
|
||||
|
||||
export default function({ spotify }: any) {
|
||||
return(
|
||||
<>
|
||||
<div className='px-8 w-11/12 m-auto rounded-lg max-w-4xl'>
|
||||
|
@ -39,7 +45,6 @@ export default function({ spotify }: any) {
|
|||
|
||||
: <a className='text-[#32a866]'> nothing</a>
|
||||
}
|
||||
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
@ -54,14 +59,4 @@ export default function({ spotify }: any) {
|
|||
<Toaster />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async () => {
|
||||
const spotify = await fetch(`${process.env.PRODUCTION}/api/spotify`, {
|
||||
method: 'GET'
|
||||
}).then((res) => res.json())
|
||||
|
||||
return {
|
||||
props: { spotify }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue