Skip to content

Commit

Permalink
chore: removed awaiting for fetch (#262)
Browse files Browse the repository at this point in the history
* feat: added cron job for spotify sync to apple-music

* chore: disabled prerendering of api routes

* chore: added log for response

* chore: added log for music url
  • Loading branch information
sarthikg authored Jan 26, 2025
1 parent 5780972 commit dc538ed
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/pages/api/music/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,14 @@ import { spotifyPlaylists } from "./_constants";
export const prerender = false;

export async function GET(): Promise<Response> {
spotifyPlaylists.forEach(async (playlist) => {
const urlSearchParams = new URLSearchParams({
playlistId: playlist.id,
});
for (let i = 0; i < spotifyPlaylists.length; i++) {
const playlist = spotifyPlaylists[i];

const urlSearchParams = new URLSearchParams({ playlistId: playlist.id });
console.log("Converting playlist:", playlist.name);
console.log(
`${import.meta.env.SITE}/api/music/sync?${urlSearchParams.toString()}`,
);
const response = await fetch(
`${import.meta.env.SITE}/api/music/sync?${urlSearchParams.toString()}`,
);
console.log(response);
if (response.status === 200) {
console.log("Converted playlist:", playlist.name);
} else {
console.log("Failed to convert playlist:", playlist.name);
}
});
const url = `${import.meta.env.SITE}/api/music/sync?${urlSearchParams.toString()}`;
const response = await fetch(url, { method: "GET" });
console.log("Response:", response.status);
}
return new Response("Submitted!", { status: 200 });
}

0 comments on commit dc538ed

Please sign in to comment.