-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPI.ts
26 lines (23 loc) · 811 Bytes
/
API.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { FeaturedPlaylists, PlaylistDetail } from './types';
const baseUrl = 'https://api.spotify.com';
const accessToken = process.env.EXPO_PUBLIC_ACCESS_TOKEN;
export async function GetPlaylists(): Promise<FeaturedPlaylists> {
let url = baseUrl + '/v1/browse/featured-playlists';
return fetch(url, {
headers: new Headers({
Authorization: `Bearer ${accessToken}`,
}),
})
.then((response) => response.json())
.catch((error) => console.error(error));
}
export async function GetPlaylistDetail(idPlayslit): Promise<PlaylistDetail> {
let url = baseUrl + '/v1/playlists/' + idPlayslit;
return fetch(url, {
headers: new Headers({
Authorization: `Bearer ${accessToken}`,
}),
})
.then((response) => response.json())
.catch((error) => console.error(error));
}