Reputation: 810
How do I use Spotifies Views API the right way?
https://developer.spotify.com/technologies/apps/docs/preview/views/index.html
I am trying to implement a throbber in a div, so I use this code:
require(['$views/throbber#Throbber'], function(Throbber) {
var favs = document.getElementById('favs');
var throbber = Throbber.forElement(favs);
});
But this is throwing an "ReferenceError: require is not defined". When I use it like this:
var sp = getSpotifyApi();
sp.require(['$views/throbber#Throbber'], function(Throbber) {
var favs = document.getElementById('favs');
var throbber = Throbber.forElement(favs);
});
It is throwing this error." TypeError: Object $views/throbber#Throbber has no method 'match' ".
Upvotes: 0
Views: 351
Reputation: 3279
The Throbber component is only available on 1.X API, using the syntax of your first code snippet.
In order to let the Spotify client know that you are using that version of the API you need to specify in your manifest.json
file that are using the 1.X API by adding a Dependencies
attribute including the api
and views
framework:
"Dependencies": {
"api": "1.0.0",
"views": "1.0.0"
}
Upvotes: 2