mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 08:08:34 +08:00
Custom: use node-fetch to post notes rather than requestUrl for better debug
This commit is contained in:
@@ -11,7 +11,7 @@ export async function updateYamlInfo(
|
||||
plugin: ObsidianSyncNotionPlugin,
|
||||
dbDetails: DatabaseDetails,
|
||||
) {
|
||||
let { url, id } = res.json
|
||||
let { url, id } = res;
|
||||
// replace www to notionID
|
||||
const { notionUser, NotionLinkDisplay } = plugin.settings;
|
||||
const { abName } = dbDetails
|
||||
|
||||
@@ -81,7 +81,7 @@ export async function uploadCommandGeneral(
|
||||
const res = await upload.syncMarkdownToNotionGeneral(basename, cover, tags, markDownData, nowFile, this.app);
|
||||
|
||||
if (res.status === 200) {
|
||||
new Notice(`${i18nConfig["sync-success"]}${basename}`).noticeEl.style.color = "green";
|
||||
new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
|
||||
} else {
|
||||
new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000);
|
||||
}
|
||||
@@ -114,8 +114,9 @@ export async function uploadCommandCustom(
|
||||
const upload = new Upload2NotionCustom(plugin, dbDetails);
|
||||
const res = await upload.syncMarkdownToNotionCustom(cover, customValues, markDownData, nowFile, this.app);
|
||||
|
||||
if (res.status === 200) {
|
||||
new Notice(`${i18nConfig["sync-success"]}${basename}`).noticeEl.style.color = "green";
|
||||
const { response } = res;
|
||||
if (response.status === 200) {
|
||||
new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
|
||||
} else {
|
||||
new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000);
|
||||
}
|
||||
|
||||
@@ -85,12 +85,18 @@ export class Upload2NotionCustom extends UploadBaseCustom {
|
||||
body: JSON.stringify(bodyString),
|
||||
});
|
||||
|
||||
const data: any = await response.json();
|
||||
if (!response.ok) {
|
||||
const data: any = await response.json();
|
||||
new Notice(`Error ${data.status}: ${data.code} \n Check the console for more information \n opt+cmd+i/ctrl+shift+i`, 5000);
|
||||
console.log(data.message);
|
||||
} else {
|
||||
return response;
|
||||
console.log(`Page created: ${data.url}`);
|
||||
console.log(`Page ID: ${data.id}`);
|
||||
}
|
||||
|
||||
return {
|
||||
response, // for status code
|
||||
data // for id and url
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,11 +134,16 @@ export class Upload2NotionCustom extends UploadBaseCustom {
|
||||
res = await this.createPage(cover, customValues, file2Block);
|
||||
}
|
||||
|
||||
if (res && res.status === 200) {
|
||||
await updateYamlInfo(markdown, nowFile, res, app, this.plugin, this.dbDetails);
|
||||
let {response, data} = res;
|
||||
|
||||
// console.log(response)
|
||||
|
||||
if (response && response.status === 200) {
|
||||
await updateYamlInfo(markdown, nowFile, data, app, this.plugin, this.dbDetails);
|
||||
} else {
|
||||
new Notice(`${res.text}`);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user