Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to import - @notionhq/client #336

Closed
aslilac opened this issue May 27, 2022 · 3 comments
Closed

Failed to import - @notionhq/client #336

aslilac opened this issue May 27, 2022 · 3 comments
Labels
deno Not working in Deno

Comments

@aslilac
Copy link

aslilac commented May 27, 2022

Failing module

import { Client } from "https://esm.sh/@notionhq/client@1.0.4?dev";

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

console.log(await notion.users.list({}));

Error message

After running deno run I got this:

Screen Shot 2022-05-26 at 10 35 24 PM

error: Uncaught TypeError: Cannot read properties of undefined (reading 'call')
    at Client2.request (https://esm.sh/v82/@notionhq/client@1.0.4/deno/client.development.js:732:130)
    at Object.list (https://esm.sh/v82/@notionhq/client@1.0.4/deno/client.development.js:684:25)
    at file:///Library/Source/flamingo/src/index.ts:3:32

Additional info

  • esm.sh version: v82
  • Deno version: v1.22.0
@aslilac aslilac added the deno Not working in Deno label May 27, 2022
@ije
Copy link
Member

ije commented May 28, 2022

@aslilac try const notion = new Client({ auth: "xxx", fetch }), this works for me. i guess the Client doesn't use the fetch api by default since the node.js only support fetch after 18, the node-fetch can not work in deno for now.

@aslilac
Copy link
Author

aslilac commented May 28, 2022

@ije aha, okay I see what's going on then.

I tried using jspm instead (which worked), but now that I look at the import map they suggested a little closer, I see what's going on: they just use node-fetch/browser be default (which seems to basically just export fetch and its associated globals)

{
	"imports": {
		"notion": "https://ga.jspm.io/npm:@notionhq/client@1.0.4/build/src/index.js",
	},
	"scopes": {
		"https://ga.jspm.io/": {
			"node-fetch": "https://ga.jspm.io/npm:node-fetch@2.6.7/browser.js"
		}
	}
}

Maybe we should do the same thing?

@ije ije closed this as completed in 469d08e May 29, 2022
@ije
Copy link
Member

ije commented May 29, 2022

i just replaced the node-fetch to node-fetch-native, no import-map needed
https://github.com/unjs/node-fetch-native

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deno Not working in Deno
Projects
None yet
Development

No branches or pull requests

2 participants