-
Notifications
You must be signed in to change notification settings - Fork 3
/
apis.js
51 lines (46 loc) · 1.16 KB
/
apis.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
41
42
43
44
45
46
47
48
49
50
51
import alfy from 'alfy'
const token = process.env.token_v2
const spaceId = process.env.space_id
const fetch = alfy.fetch
export const fetchSpaceInfo = async () => {
let result = alfy.cache.get('spaceInfo')
if (result) return result
result = await fetch('https://www.notion.so/api/v3/getPublicSpaceData', {
method: 'POST',
headers: {
accept: '*/*',
'content-type': 'application/json'
},
body: { type: 'space-ids', spaceIds: [spaceId] }
})
alfy.cache.set('spaceInfo', result)
return result
}
export const search = async (q) =>
fetch('https://www.notion.so/api/v3/search', {
method: 'POST',
headers: {
cookie: `token_v2=${token}`,
accept: '*/*',
'content-type': 'application/json'
},
body: {
type: 'BlocksInSpace',
query: q,
spaceId,
limit: 20,
filters: {
isDeletedOnly: false,
excludeTemplates: false,
isNavigableOnly: false,
requireEditPermissions: false,
ancestors: [],
createdBy: [],
editedBy: [],
lastEditedTime: {},
createdTime: {}
},
sort: 'Relevance',
source: 'quick_find'
}
})