Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/spotify-web-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ SpotifyWebApi.prototype = {
return this._credentials;
},

setDefaultHeaders: function(defaultHeaders) {
WebApiRequest.setDefaultHeaders(defaultHeaders);
},

resetCredentials: function() {
this._credentials = null;
},
Expand Down Expand Up @@ -593,7 +597,7 @@ SpotifyWebApi.prototype = {
.withBodyParameters(
{
tracks: tracks
},
},
options
)
.build()
Expand Down Expand Up @@ -971,7 +975,7 @@ SpotifyWebApi.prototype = {
},


/**
/**
* Get the Current User's Available Devices
* @param {requestCallback} [callback] Optional callback method to be called instead of the promise.
* @returns {Promise|undefined} A promise that if successful, resolves into an array of device objects,
Expand Down Expand Up @@ -1016,7 +1020,7 @@ SpotifyWebApi.prototype = {

/**
* Transfer a User's Playback
* @param {string[]} [deviceIds] An _array_ containing a device ID on which playback should be started/transferred.
* @param {string[]} [deviceIds] An _array_ containing a device ID on which playback should be started/transferred.
* (NOTE: The API is currently only supporting a single device ID.)
* @param {Object} [options] Options, the only one being 'play'.
* @param {requestCallback} [callback] Optional callback method to be called instead of the promise.
Expand Down Expand Up @@ -1175,7 +1179,7 @@ SpotifyWebApi.prototype = {

/**
* Set Shuffle Mode On The Current User's Playback
* @param {boolean} [state] State
* @param {boolean} [state] State
* @param {Object} [options] Options, being device_id. If left empty will target the user's currently active device.
* @param {requestCallback} [callback] Optional callback method to be called instead of the promise.
* @example setShuffle({state: 'false'}).then(...)
Expand Down
7 changes: 7 additions & 0 deletions src/webapi-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ var DEFAULT_HOST = 'api.spotify.com',
DEFAULT_PORT = 443,
DEFAULT_SCHEME = 'https';

let defaultHeaders = null;

module.exports.builder = function(accessToken) {
return Request.builder()
.withHost(DEFAULT_HOST)
.withPort(DEFAULT_PORT)
.withScheme(DEFAULT_SCHEME)
.withHeaders(defaultHeaders)
.withAuth(accessToken);
};

module.exports.setDefaultHeaders = function(headers) {
defaultHeaders = headers;
}