mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2026-01-25 06:04:05 +00:00
been a while
This commit is contained in:
@@ -65,13 +65,18 @@ const callback = async (req, res) => {
|
||||
const response = await authInstance.post('/api/token', authPayload);
|
||||
|
||||
if (response.status === 200) {
|
||||
logger.info('New login.');
|
||||
req.session.accessToken = response.data.access_token;
|
||||
req.session.refreshToken = response.data.refresh_token;
|
||||
req.session.cookie.maxAge = response.data.expires_in * 1000;
|
||||
|
||||
req.session.save((err) => { if (err) throw err; });
|
||||
req.session.save((err) => {
|
||||
if (err) {
|
||||
logger.error("redis session save error", { sessionError: err })
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
logger.info('New login.')
|
||||
return res.status(200).send({
|
||||
message: "Login successful",
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user