-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeezer.js
40 lines (33 loc) · 787 Bytes
/
deezer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import DZ from 'node-deezer'
import Promise from 'bluebird'
const deezer = new DZ()
export const deezerRequest = (accessToken, action, query) => {
return new Promise((resolve, reject) => {
deezer.request(accessToken,
{
resource: action,
method: 'get',
fields: query,
},
(err, result = {}) => {
if (err) {
return reject(err)
}
const {
data = null
} = result
return resolve(data)
})
})
}
export const deezerCreateSession = (appId, appSecret, code) => {
return new Promise((resolve, reject) => {
deezer.createSession(appId, appSecret, code, (err, result) => {
if (err) {
return reject(err)
}
return resolve(result.accessToken)
})
})
}
export default deezer