been a while

This commit is contained in:
2023-09-24 19:27:04 -07:00
parent d4a6424fd0
commit 3f4bc3b8e9
7 changed files with 565 additions and 321 deletions

View File

@@ -10,6 +10,8 @@ const { axiosInstance } = require('../axios');
*/
const getUserPlaylists = async (req, res) => {
try {
let playlists = {};
// get first 50
const response = await axiosInstance.get(
"/me/playlists",
@@ -24,8 +26,6 @@ const getUserPlaylists = async (req, res) => {
}
);
let playlists = {};
playlists.items = response.data.items.map((playlist) => {
return {
name: playlist.name,
@@ -42,10 +42,10 @@ const getUserPlaylists = async (req, res) => {
playlists.total = response.data.total;
playlists.next = response.data.next;
// keep getting batches of 50 more till exhausted
// keep getting batches of 50 till exhausted
while (playlists.next) {
const nextResponse = await axiosInstance.get(
playlists.next, // absolute URL which has params
playlists.next, // absolute URL from previous response which has offset and limit params
{
headers: {
...req.authHeader