Skip to content

Commit

Permalink
added correct return statement
Browse files Browse the repository at this point in the history
  • Loading branch information
synan798 authored and Likqez committed Dec 2, 2024
1 parent 04328b0 commit 6a2bb13
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/api/v1/playlist/index.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ export default defineEventHandler(async (event) => {
}));

const client = serverSupabaseServiceRole(event);
const {data, error} = await client.from('playlists').insert(playlistInsert as never).select().single(); //todo: fix type error!
const {data: playlistData, error: playlistError} = await client.from('playlists').insert(playlistInsert as never).select().single(); //todo: fix type error!


if (error) {
if (playlistError) {
setResponseStatus(event, 400);
if (error.code === UNIQUE_VIOLATION)
if (playlistError.code === UNIQUE_VIOLATION)
return {error: 'Playlist with this ID already exists'};
setResponseStatus(event, 500);
return {error: error.message};
return {error: playlistError.message};
}

const { data: categoriesData, error: categoriesError } = await client
Expand All @@ -66,5 +66,5 @@ export default defineEventHandler(async (event) => {


setResponseStatus(event, 201);
return data;
return { playlist: playlistData, categories: categoriesData };
})

0 comments on commit 6a2bb13

Please sign in to comment.