Skip to content

Commit

Permalink
updated playlist api
Browse files Browse the repository at this point in the history
  • Loading branch information
gnehs committed Nov 1, 2021
1 parent db91006 commit c08a618
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion router/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ async function checkPlaylistOwner(playlistId, userId) {
}
router.post("/create", async (req, res) => {
let { name } = req.body
if (!name) {
res.status(400).send("name is required")
return
}
res.json(await playlistDB.createPlaylist(name, req.session.user))
})
router.post("/del", async (req, res) => {
Expand All @@ -36,7 +40,7 @@ router.post("/edit", async (req, res) => {
})
router.post("/song/exist", async (req, res) => {
let song = req.body
let playlists = await playlistDB.getPlaylists(req.session.user)
let playlists = (await playlistDB.getPlaylists(req.session.user)).map(x => ({ id: x._id, ...JSON.parse(JSON.stringify(x)) }))
let result = {
playlists: [],
existsPlaylists: []
Expand Down

0 comments on commit c08a618

Please sign in to comment.