Re:MusicKit JS
by benbristow on Saturday February 22, 2020 @02:29PM
(#22392806)
Doesn’t seem like there’s an NPM package. Would be better if you could import it with Webpack and use await rather than callbacks etc.
[ Parent
| on HN ]
Re:MusicKit JS
by mrcarruthers on Saturday February 22, 2020 @03:08PM
(#22393027)
Well it's using promises, so you can just await those.
But agreed, the documentation looks like it was written in 2014/2015.
The "user's cloudAlbums" example is awful. Might as well use callbacks if you aren't gonna chain promises to avoid callback hell.
Where is that? Link?
Under the "JavaScript Methods" heading
https://developer.apple.com/documentation/musickitjs#3004817
music.authorize().then(function() {
music.api.library.albums.then(function(cloudAlbums) {
// user's cloudAlbums
});
});
Should be:
music.authorize().then(function() {
return music.api.library.albums;
}).then(function (cloudAlbums) {
// user's cloudAlbums
});