fix: handle errors better
This commit is contained in:
parent
a8071a5415
commit
8ea6313969
2 changed files with 4 additions and 1 deletions
|
@ -85,6 +85,7 @@ export default async () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
if (data.status) return {}
|
||||||
if (data.ok) return data?.json();
|
if (data.ok) return data?.json();
|
||||||
throw new Error('Something went wrong with the Trakt endpoint.');
|
throw new Error('Something went wrong with the Trakt endpoint.');
|
||||||
})
|
})
|
||||||
|
@ -113,6 +114,8 @@ export default async () => {
|
||||||
|
|
||||||
const scrobbleData = await scrobbles.get('now-playing', { type: 'json'})
|
const scrobbleData = await scrobbles.get('now-playing', { type: 'json'})
|
||||||
|
|
||||||
|
if (!scrobbleData) return new Response(JSON.stringify({}, { headers }))
|
||||||
|
|
||||||
return new Response(JSON.stringify({
|
return new Response(JSON.stringify({
|
||||||
content: `${emojiMap(
|
content: `${emojiMap(
|
||||||
scrobbleData['genre'],
|
scrobbleData['genre'],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "10.1.1",
|
"version": "10.1.2",
|
||||||
"description": "The source for my personal site. Built using 11ty.",
|
"description": "The source for my personal site. Built using 11ty.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Reference in a new issue