async function getNotionDb(token, db) {
try {
if (!db) {
const res = await fetch(
`https://notion2json.herokuapp.com/databases?token=${token}`
);
const source = JSON.parse(await res.text());
return source;
} else {
const resdb = await fetch(
`https://notion2json.herokuapp.com/database?token=${token}&id=${db}`
);
const sourcedb = JSON.parse(await resdb.text());
return sourcedb;
}
} catch (error) {
return "token or id invalid";
}
}