From 86e54c0032cdc347d9eca71e724ba47bba228278 Mon Sep 17 00:00:00 2001 From: CeBkCn Date: Thu, 7 Jul 2016 17:06:15 +0800 Subject: [PATCH] Add getPlaylists --- src/component/getPlaylists.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/component/getPlaylists.js diff --git a/src/component/getPlaylists.js b/src/component/getPlaylists.js new file mode 100644 index 0000000..7c35a36 --- /dev/null +++ b/src/component/getPlaylists.js @@ -0,0 +1,19 @@ +import request from 'request' +import { origin, globalOption } from '../config' +import { deepCopy } from '../util' + +const getPlaylists = (id, callback) => { + const option = deepCopy(globalOption) + const url = `${origin}/api/playlist/detail?id=${id}` + const method = 'get' + Object.assign(option, {url, method}) + request(option, (err, res, body) => { + if(!err && res.statusCode == 200) { + let info = JSON.parse(body) + callback && callback(JSON.stringify(info, '', 2)) + } else { + console.error(err); + } + }) +} +export { Playlists }