NPM compatibility

notion.databases.query works under nodejs but fails for me under Deno. it lints and checks ok and doesn't complain when I start it up
deno run --allow-read --allow-env --allow-net --unstable into_notion.ts
deno run --allow-read --allow-env --allow-net --unstable into_notion.ts
but i get this error when I try to run it. the API token is being properly read from .env and is identical to what the nodejs program is using. Where do I go from here?
@notionhq/client warn: request fail { code: "unauthorized", message: "API token is invalid." }
APIResponseError: API token is invalid.
at buildRequestError (file:///Users/dan/Library/Caches/deno/npm/registry.npmjs.org/@notionhq/client/2.2.1/build/src/errors.js:162:16)
at Client.request (file:///Users/dan/Library/Caches/deno/npm/registry.npmjs.org/@notionhq/client/2.2.1/build/src/Client.js:342:54)
at Object.runMicrotasks (deno:core/01_core.js:297:30)
at processTicksAndRejections (https://deno.land/std@0.157.0/node/_next_tick.ts:62:10)
at async main (file:///Users/dan/xall/STUFF/src/exp/into_notion.ts:16:20)
@notionhq/client warn: request fail { code: "unauthorized", message: "API token is invalid." }
APIResponseError: API token is invalid.
at buildRequestError (file:///Users/dan/Library/Caches/deno/npm/registry.npmjs.org/@notionhq/client/2.2.1/build/src/errors.js:162:16)
at Client.request (file:///Users/dan/Library/Caches/deno/npm/registry.npmjs.org/@notionhq/client/2.2.1/build/src/Client.js:342:54)
at Object.runMicrotasks (deno:core/01_core.js:297:30)
at processTicksAndRejections (https://deno.land/std@0.157.0/node/_next_tick.ts:62:10)
at async main (file:///Users/dan/xall/STUFF/src/exp/into_notion.ts:16:20)
source code below
import parentClient from "npm:@notionhq/client";
const { Client } = parentClient;
import { load } from "https://deno.land/x/denv@3.0.0/mod.ts";
await load({});
const token = Deno.env.get("NOTION_TOKEN");

async function main() {
console.log(`***token <${token}>`);

const notion = new Client({
auth: token,
});

const response = await notion.databases.query({
database_id: "af446fef53c84862b16c66233adcce3b",
});

console.log("Got response:", response);
}

main()
.then(() => console.log("success"))
.catch((err) => {
console.error(err);
});
import parentClient from "npm:@notionhq/client";
const { Client } = parentClient;
import { load } from "https://deno.land/x/denv@3.0.0/mod.ts";
await load({});
const token = Deno.env.get("NOTION_TOKEN");

async function main() {
console.log(`***token <${token}>`);

const notion = new Client({
auth: token,
});

const response = await notion.databases.query({
database_id: "af446fef53c84862b16c66233adcce3b",
});

console.log("Got response:", response);
}

main()
.then(() => console.log("success"))
.catch((err) => {
console.error(err);
});
`
0 Replies
No replies yetBe the first to reply to this messageJoin