Comparing version 0.5.0-next.3 to 0.5.0
{ | ||
"name": "notabase", | ||
"version": "0.5.0-next.3", | ||
"version": "0.5.0", | ||
"description": "API Wrapper For Notion's Database", | ||
@@ -5,0 +5,0 @@ "main": "src/notabase.js", |
const token_v2 = undefined | ||
const cookies = `token_v2=${token_v2}` | ||
const cookie = `token_v2=${token_v2}` | ||
const AUTH_CODE = 'nobody knows but you' | ||
@@ -57,5 +57,6 @@ | ||
// 本人操作 | ||
addHeader = { cookies } | ||
// cookie NOT cookies | ||
addHeader = { cookie } | ||
} | ||
// todo 针对 CUD 请求添加 cookies | ||
// todo 针对 CUD 请求添加 cookie | ||
response = await fetch(`https://www.notion.so${url.pathname}`, { | ||
@@ -62,0 +63,0 @@ body: body, // must match 'Content-Type' header |
const NOTION_BASE_URL = "https://www.notion.so" | ||
const NOTION_PROXY_API_URL = "https://notion.gine.workers.dev" | ||
@@ -38,3 +37,3 @@ | ||
this.token = token | ||
let tkHeader = token ? { 'cookies': token } : {} | ||
let tkHeader = token ? { 'cookie': `token_v2=${token}` } : {} | ||
const fetch = require("node-fetch") | ||
@@ -47,3 +46,6 @@ this.reqeust = { | ||
headers: { | ||
'accept-encoding': 'gzip, deflate', | ||
'content-length': JSON.stringify(data).length, | ||
'content-type': 'application/json;charset=UTF-8', | ||
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36', | ||
...tkHeader | ||
@@ -50,0 +52,0 @@ }, |
30
test.js
@@ -1,2 +0,2 @@ | ||
const Notabase = require('././src/notabase') | ||
const Notabase = require('./src/notabase') | ||
@@ -8,16 +8,20 @@ | ||
t = async () => { | ||
let db = await nb.fetch({ | ||
songs: "https://www.notion.so/2628769120ad41d998ec068d6e2eb410?v=e8e69ac68a8d483792c54541e4d8ba72", | ||
artists: "https://www.notion.so/15f1759f38a34fedaa79262812b707f0?v=b385656739214101b2b8a159092a52e8", | ||
albums: "https://www.notion.so/31b8544ffb034964b1aa56bfa78497c1?v=1d9cbfcd279d4534964acdd374c9824e" | ||
}) | ||
// console.log(db.songs.rows.find(item => item.title === '风衣').album[0].Name) | ||
// 孙燕姿No. 13作品:跳舞的梵谷 | ||
let db = await nb._fetch("https://www.notion.so/gine/207fde2f97814adf964fb279382df205?v=f4fc2aad01a946999558111059d132d2") | ||
let song = db.songs.rows.find(item => item.title === "Tonight, I Feel Close To You") | ||
song.artist.map(a => { | ||
console.log(a.Name) | ||
console.log(a.songs) | ||
}) | ||
console.log(db) | ||
// let db = await nb.fetch({ | ||
// songs: "https://www.notion.so/2628769120ad41d998ec068d6e2eb410?v=e8e69ac68a8d483792c54541e4d8ba72", | ||
// artists: "https://www.notion.so/15f1759f38a34fedaa79262812b707f0?v=b385656739214101b2b8a159092a52e8", | ||
// albums: "https://www.notion.so/31b8544ffb034964b1aa56bfa78497c1?v=1d9cbfcd279d4534964acdd374c9824e" | ||
// }) | ||
// // console.log(db.songs.rows.find(item => item.title === '风衣').album[0].Name) | ||
// // 孙燕姿No. 13作品:跳舞的梵谷 | ||
// let song = db.songs.rows.find(item => item.title === "Tonight, I Feel Close To You") | ||
// song.artist.map(a => { | ||
// console.log(a.Name) | ||
// console.log(a.songs) | ||
// }) | ||
// 倉木麻衣 | ||
@@ -24,0 +28,0 @@ // 孙燕姿 |
5
20106
8
386