From 2b6124cbf93d039a98171ad02a358827a836ad26 Mon Sep 17 00:00:00 2001 From: arch0Xd <71967828+arch0Xd@users.noreply.github.com> Date: Sun, 14 Aug 2022 18:37:24 +0200 Subject: [PATCH] nem is spotify hanem lastfm --- pages/api/spotify.ts | 4 ++-- pages/index.tsx | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/pages/api/spotify.ts b/pages/api/spotify.ts index 9e5a18b..424b28b 100644 --- a/pages/api/spotify.ts +++ b/pages/api/spotify.ts @@ -13,7 +13,7 @@ export default async function(req: NextApiRequest, res: NextApiResponse) { let nowplaying = Boolean(track[0]['@attr']?.nowplaying) if(nowplaying) { - res.status(200).json({ + return res.status(200).json({ nowplaying, song: { artist: artist['#text'], @@ -24,5 +24,5 @@ export default async function(req: NextApiRequest, res: NextApiResponse) { }) } - res.status(200).json({ nowplaying }) + return res.status(200).json({ nowplaying }) } \ No newline at end of file diff --git a/pages/index.tsx b/pages/index.tsx index 65895e5..c547b6c 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,14 +1,16 @@ import Image from 'next/image' +import Link from 'next/link' import React from 'react' import { socials } from 'components/data/socials' - import { Icon } from 'components/Icon' -import { Toaster } from 'react-hot-toast' -import { GetServerSideProps } from 'next' -import { FaSpotify } from 'react-icons/fa' import { Footer } from 'components/Footer' +import { Toaster } from 'react-hot-toast' +import { FaSpotify } from 'react-icons/fa' + +import { GetServerSideProps } from 'next' + export default function({ spotify }: any) { return( <> @@ -28,8 +30,16 @@ export default function({ spotify }: any) {
Listening to - { spotify.song?.artist - spotify.song?.title || 'nothing' } +
Listening to + { + spotify.song + ? + { spotify.song.artist + ' - ' + spotify.song.title } + + + : nothing + } +