mirror of
https://github.com/skidoodle/albert.lol.git
synced 2025-02-15 06:09:15 +01:00
Prettier and a new readme
This commit is contained in:
parent
146b35d1d3
commit
f21d8f8086
16 changed files with 352 additions and 2594 deletions
|
@ -1,26 +1,28 @@
|
|||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
export default async function(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { LASTFM_USERNAME, LASTFM_API } = process.env
|
||||
export default async function (req: NextApiRequest, res: NextApiResponse) {
|
||||
const { LASTFM_USERNAME, LASTFM_API } = process.env;
|
||||
|
||||
const { recenttracks: response } = await fetch(`https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=${LASTFM_USERNAME}&api_key=${LASTFM_API}&format=json&limit=1`).then((res) => res.json())
|
||||
const { recenttracks: response } = await fetch(
|
||||
`https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=${LASTFM_USERNAME}&api_key=${LASTFM_API}&format=json&limit=1`
|
||||
).then((res) => res.json());
|
||||
|
||||
const { track } = response
|
||||
const { artist, name, url, image } = track[0]
|
||||
const { track } = response;
|
||||
const { artist, name, url, image } = track[0];
|
||||
|
||||
let nowplaying = Boolean(track[0]['@attr']?.nowplaying)
|
||||
let nowplaying = Boolean(track[0]["@attr"]?.nowplaying);
|
||||
|
||||
if(nowplaying) {
|
||||
return res.status(200).json({
|
||||
nowplaying,
|
||||
song: {
|
||||
artist: artist['#text'],
|
||||
title: name,
|
||||
url: url,
|
||||
image: image[2]['#text'],
|
||||
}
|
||||
})
|
||||
}
|
||||
if (nowplaying) {
|
||||
return res.status(200).json({
|
||||
nowplaying,
|
||||
song: {
|
||||
artist: artist["#text"],
|
||||
title: name,
|
||||
url: url,
|
||||
image: image[2]["#text"],
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).json({ nowplaying })
|
||||
}
|
||||
return res.status(200).json({ nowplaying });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue