ocd formatting, changed user object, retrieve user ID

This commit is contained in:
2024-07-25 09:05:41 +05:30
parent 40cf0c2e2b
commit f067320a7f
21 changed files with 112 additions and 104 deletions

View File

@@ -14,7 +14,7 @@ const getUserPlaylists = async (req, res) => {
// get first 50
const response = await axiosInstance.get(
"/me/playlists",
`/users/${req.session.user.id}/playlists`,
{
params: {
offset: 0,
@@ -26,7 +26,7 @@ const getUserPlaylists = async (req, res) => {
}
);
if (response.status === 401) {
if (response.status === 401) {
return res.status(401).send(response.data);
}
@@ -34,9 +34,7 @@ const getUserPlaylists = async (req, res) => {
playlists.items = response.data.items.map((playlist) => {
return {
name: playlist.name,
description: playlist.description,
owner_name: playlist.owner.display_name,
id: playlist.id,
id: playlist.id
}
});
@@ -60,9 +58,7 @@ const getUserPlaylists = async (req, res) => {
...nextResponse.data.items.map((playlist) => {
return {
name: playlist.name,
description: playlist.description,
owner_name: playlist.owner.display_name,
id: playlist.id,
id: playlist.id
}
})
);
@@ -70,6 +66,8 @@ const getUserPlaylists = async (req, res) => {
playlists.next = nextResponse.data.next;
}
delete playlists.next;
return res.status(200).send(playlists);
} catch (error) {
logger.error('getUserPlaylists', { error });
@@ -161,5 +159,5 @@ const getPlaylistDetails = async (req, res) => {
module.exports = {
getUserPlaylists,
getPlaylistDetails,
};
getPlaylistDetails
};