-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtopic.coffee
52 lines (47 loc) · 1.11 KB
/
topic.coffee
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
41
42
43
44
45
46
47
48
49
50
51
52
'use strict'
reqwest = require('reqwest')
configs = require('../configs')
exports.getList = (page, cb) ->
reqwest
url: "#{configs.domain}/api/v1/topics"
type: 'json'
data:
page: page
limit: 40
method: 'get'
contentType: 'application/json'
success: (data) ->
cb data.data
error: (_error) ->
console.log 'error', _error
exports.get = (id, cb) ->
reqwest
url: "#{configs.domain}/api/v1/topic/#{id}"
data: [ {
name: 'mdrender'
value: false
} ]
type: 'json'
method: 'get'
contentType: 'application/json'
success: (data) ->
cb data.data
error: (_error2) ->
console.log 'error', _error2
exports.create = (data, token, cb) ->
reqwest
url: "#{configs.domain}/api/v1/topics"
data: JSON.stringify(
title: data.title
content: data.content
tab: data.tab
accesstoken: token)
type: 'json'
method: 'post'
contentType: 'application/json'
success: (data) ->
cb data.topic_id
error: (_error3) ->
console.log 'error', _error3
exports.collect = ->
exports.deCollection = ->