spotify-web-api-ts
Advanced tools
Comparing version 1.4.2 to 1.4.3
@@ -22,3 +22,3 @@ "use strict"; | ||
const response = yield this.http.get('/albums', { | ||
params: Object.assign(Object.assign({}, options), { ids: albumIds.join(',') }), | ||
params: Object.assign(Object.assign({}, options), { ids: albumIds }), | ||
}); | ||
@@ -25,0 +25,0 @@ return response.albums; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const qs_1 = __importDefault(require("qs")); | ||
const constants_1 = require("../constants"); | ||
const stringifyParams_1 = require("./stringifyParams"); | ||
function getAuthorizationUrl(clientId, redirectUri, responseType, options) { | ||
return `${constants_1.AUTHORIZE_URL}?${stringifyParams_1.stringifyParams(Object.assign(Object.assign(Object.assign({ client_id: clientId, redirect_uri: redirectUri, response_type: responseType }, ((options === null || options === void 0 ? void 0 : options.scope) && { scope: options.scope.join(' ') })), ((options === null || options === void 0 ? void 0 : options.show_dialog) && { show_dialog: options.show_dialog })), ((options === null || options === void 0 ? void 0 : options.state) && { state: options.state })))}`; | ||
return `${constants_1.AUTHORIZE_URL}?${qs_1.default.stringify(Object.assign(Object.assign(Object.assign({}, options), { client_id: clientId, redirect_uri: redirectUri, response_type: responseType }), ((options === null || options === void 0 ? void 0 : options.scope) && { scope: options.scope.join(' ') })))}`; | ||
} | ||
exports.getAuthorizationUrl = getAuthorizationUrl; | ||
//# sourceMappingURL=getAuthorizationUrl.js.map |
@@ -1,2 +0,2 @@ | ||
import { Method, AxiosRequestConfig } from 'axios'; | ||
import { AxiosRequestConfig, Method } from 'axios'; | ||
export declare type SpotifyAxiosConfig = AxiosRequestConfig & { | ||
@@ -6,1 +6,2 @@ contentType?: string; | ||
export declare function spotifyAxios<T>(url: string, method: Method, accessToken: string, config?: SpotifyAxiosConfig): Promise<T>; | ||
export declare function paramsSerializer(params: any): string; |
@@ -27,2 +27,3 @@ "use strict"; | ||
const axios_1 = __importDefault(require("axios")); | ||
const qs_1 = __importDefault(require("qs")); | ||
const constants_1 = require("../constants"); | ||
@@ -36,3 +37,4 @@ function spotifyAxios(url, method, accessToken, config) { | ||
'Content-Type': contentType !== null && contentType !== void 0 ? contentType : 'application/json', | ||
}, url, | ||
}, paramsSerializer, | ||
url, | ||
method })); | ||
@@ -48,2 +50,6 @@ return response.data; | ||
exports.spotifyAxios = spotifyAxios; | ||
function paramsSerializer(params) { | ||
return qs_1.default.stringify(params, { arrayFormat: 'comma' }); | ||
} | ||
exports.paramsSerializer = paramsSerializer; | ||
//# sourceMappingURL=spotifyAxios.js.map |
@@ -16,2 +16,3 @@ "use strict"; | ||
const axios_1 = __importDefault(require("axios")); | ||
const qs_1 = __importDefault(require("qs")); | ||
const AlbumsApi_1 = require("./apis/AlbumsApi"); | ||
@@ -34,3 +35,2 @@ const ArtistsApi_1 = require("./apis/ArtistsApi"); | ||
const Http_1 = require("./helpers/Http"); | ||
const stringifyParams_1 = require("./helpers/stringifyParams"); | ||
class SpotifyWebApi { | ||
@@ -80,3 +80,3 @@ constructor(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield axios_1.default.post(constants_1.TOKEN_URL, stringifyParams_1.stringifyParams({ | ||
const response = yield axios_1.default.post(constants_1.TOKEN_URL, qs_1.default.stringify({ | ||
code, | ||
@@ -96,3 +96,3 @@ grant_type: 'authorization_code', | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield axios_1.default.post(constants_1.TOKEN_URL, stringifyParams_1.stringifyParams({ | ||
const response = yield axios_1.default.post(constants_1.TOKEN_URL, qs_1.default.stringify({ | ||
grant_type: 'refresh_token', | ||
@@ -111,3 +111,3 @@ refresh_token: refreshToken, | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield axios_1.default.post(constants_1.TOKEN_URL, stringifyParams_1.stringifyParams({ | ||
const response = yield axios_1.default.post(constants_1.TOKEN_URL, qs_1.default.stringify({ | ||
grant_type: 'client_credentials', | ||
@@ -114,0 +114,0 @@ }), { |
@@ -20,3 +20,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const response = yield this.http.get('/albums', { | ||
params: Object.assign(Object.assign({}, options), { ids: albumIds.join(',') }), | ||
params: Object.assign(Object.assign({}, options), { ids: albumIds }), | ||
}); | ||
@@ -23,0 +23,0 @@ return response.albums; |
@@ -0,6 +1,6 @@ | ||
import qs from 'qs'; | ||
import { AUTHORIZE_URL } from '../constants'; | ||
import { stringifyParams } from './stringifyParams'; | ||
export function getAuthorizationUrl(clientId, redirectUri, responseType, options) { | ||
return `${AUTHORIZE_URL}?${stringifyParams(Object.assign(Object.assign(Object.assign({ client_id: clientId, redirect_uri: redirectUri, response_type: responseType }, ((options === null || options === void 0 ? void 0 : options.scope) && { scope: options.scope.join(' ') })), ((options === null || options === void 0 ? void 0 : options.show_dialog) && { show_dialog: options.show_dialog })), ((options === null || options === void 0 ? void 0 : options.state) && { state: options.state })))}`; | ||
return `${AUTHORIZE_URL}?${qs.stringify(Object.assign(Object.assign(Object.assign({}, options), { client_id: clientId, redirect_uri: redirectUri, response_type: responseType }), ((options === null || options === void 0 ? void 0 : options.scope) && { scope: options.scope.join(' ') })))}`; | ||
} | ||
//# sourceMappingURL=getAuthorizationUrl.js.map |
@@ -1,2 +0,2 @@ | ||
import { Method, AxiosRequestConfig } from 'axios'; | ||
import { AxiosRequestConfig, Method } from 'axios'; | ||
export declare type SpotifyAxiosConfig = AxiosRequestConfig & { | ||
@@ -6,1 +6,2 @@ contentType?: string; | ||
export declare function spotifyAxios<T>(url: string, method: Method, accessToken: string, config?: SpotifyAxiosConfig): Promise<T>; | ||
export declare function paramsSerializer(params: any): string; |
@@ -22,2 +22,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import axios from 'axios'; | ||
import qs from 'qs'; | ||
import { BASE_API_URL } from '../constants'; | ||
@@ -31,3 +32,4 @@ export function spotifyAxios(url, method, accessToken, config) { | ||
'Content-Type': contentType !== null && contentType !== void 0 ? contentType : 'application/json', | ||
}, url, | ||
}, paramsSerializer, | ||
url, | ||
method })); | ||
@@ -42,2 +44,5 @@ return response.data; | ||
} | ||
export function paramsSerializer(params) { | ||
return qs.stringify(params, { arrayFormat: 'comma' }); | ||
} | ||
//# sourceMappingURL=spotifyAxios.js.map |
@@ -11,2 +11,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import axios from 'axios'; | ||
import qs from 'qs'; | ||
import { AlbumsApi } from './apis/AlbumsApi'; | ||
@@ -29,3 +30,2 @@ import { ArtistsApi } from './apis/ArtistsApi'; | ||
import { Http } from './helpers/Http'; | ||
import { stringifyParams } from './helpers/stringifyParams'; | ||
export class SpotifyWebApi { | ||
@@ -75,3 +75,3 @@ constructor(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield axios.post(TOKEN_URL, stringifyParams({ | ||
const response = yield axios.post(TOKEN_URL, qs.stringify({ | ||
code, | ||
@@ -91,3 +91,3 @@ grant_type: 'authorization_code', | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield axios.post(TOKEN_URL, stringifyParams({ | ||
const response = yield axios.post(TOKEN_URL, qs.stringify({ | ||
grant_type: 'refresh_token', | ||
@@ -106,3 +106,3 @@ refresh_token: refreshToken, | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield axios.post(TOKEN_URL, stringifyParams({ | ||
const response = yield axios.post(TOKEN_URL, qs.stringify({ | ||
grant_type: 'client_credentials', | ||
@@ -109,0 +109,0 @@ }), { |
{ | ||
"name": "spotify-web-api-ts", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"description": "An isomorphic TypeScript wrapper for Spotify's Web API", | ||
@@ -35,2 +35,3 @@ "main": "cjs/index.js", | ||
"@spotify/web-scripts": "^7.0.1", | ||
"@types/qs": "^6.9.3", | ||
"husky": "^4.2.5", | ||
@@ -40,4 +41,5 @@ "typedoc": "^0.17.7" | ||
"dependencies": { | ||
"axios": "^0.19.2" | ||
"axios": "^0.19.2", | ||
"qs": "^6.9.4" | ||
} | ||
} |
@@ -45,5 +45,3 @@ <p align="center"> | ||
const spotify = new SpotifyWebApi({ | ||
accessToken: '<YOUR_ACCESS_TOKEN_HERE>', | ||
}); | ||
const spotify = new SpotifyWebApi({ accessToken: '<YOUR_ACCESS_TOKEN_HERE>' }); | ||
@@ -53,3 +51,3 @@ const { artists } = await spotify.albums.getAlbum('1uzfGk9vxMXfaZ2avqwxod'); | ||
console.log(artists.map(artist => artist.name)); | ||
// ['Against All Logic'] | ||
// Array [ "Against All Logic" ] | ||
``` |
@@ -1,2 +0,2 @@ | ||
import { Method, AxiosRequestConfig } from 'axios'; | ||
import { AxiosRequestConfig, Method } from 'axios'; | ||
export declare type SpotifyAxiosConfig = AxiosRequestConfig & { | ||
@@ -6,2 +6,3 @@ contentType?: string; | ||
export declare function spotifyAxios<T>(url: string, method: Method, accessToken: string, config?: SpotifyAxiosConfig): Promise<T>; | ||
export declare function paramsSerializer(params: any): string; | ||
//# sourceMappingURL=spotifyAxios.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
5000
287628
2
4
196
52
+ Addedqs@^6.9.4
+ Addedcall-bind@1.0.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedobject-inspect@1.13.1(transitive)
+ Addedqs@6.12.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)