(mediaType: string, mediaIds: string[])
| 63 | } |
| 64 | |
| 65 | export async function addToLibrary(mediaType: string, mediaIds: string[]) { |
| 66 | try { |
| 67 | await axios({ |
| 68 | method: 'post', |
| 69 | url: `${API_URL}/v1/me/library?ids[${mediaType}]=${mediaIds.map(m => m).join(',')}`, |
| 70 | headers: getHeaders(), |
| 71 | }); |
| 72 | Alert.success("Added tracks to your library, they'll show up in a few seconds. Hold tight!"); |
| 73 | } catch (error) { |
| 74 | Alert.error("We're unable to add these tracks to your library."); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | export function getHeaders() { |
| 79 | const music = MusicKit.getInstance(); |
no test coverage detected